ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2024-08-05 05:53:33
Exec Total Coverage
Lines: 9085 12001 75.7%
Functions: 354 407 87.0%
Branches: 7238 12752 56.8%

Line Branch Exec Source
1 #include <cstring>
2 #include <stdio.h>
3 #include "base/zc_alleg.h"
4 #include "zc/guys.h"
5 #include "zc/replay.h"
6 #include "zc/zc_ffc.h"
7 #include "zc/zelda.h"
8 #include "base/zsys.h"
9 #include "base/msgstr.h"
10 #include "zc/maps.h"
11 #include "zc/hero.h"
12 #include "subscr.h"
13 #include "zc/ffscript.h"
14 #include "gamedata.h"
15 #include "defdata.h"
16 #include "zscriptversion.h"
17 #include "particles.h"
18 #include "base/zc_math.h"
19 #include "slopes.h"
20 #include "base/qrs.h"
21 #include "base/dmap.h"
22 #include "base/mapscr.h"
23 #include "base/misctypes.h"
24 #include "base/initdata.h"
25 #include "zc/combos.h"
26 extern particle_list particles;
27
28 extern FFScript FFCore;
29 extern ZModule zcm;
30 extern HeroClass Hero;
31 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
32
33 int32_t repaircharge=0;
34 bool adjustmagic=false;
35 bool learnslash=false;
36 int32_t wallm_load_clk=0;
37 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
38 int32_t vhead=0;
39 int32_t guycarryingitem=0;
40
41 char *guy_string[eMAXGUYS];
42
43 void never_return(int32_t index);
44 void playLevelMusic();
45
46 // If an enemy is this far out of the playing field, just remove it.
47 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
48 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
49 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
50 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
51
52 1111957 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
53 {
54 1111957 int32_t c = coord.getInt();
55
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 1111690 times.
1111957 if(nearest_half)
56 {
57
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1111690 times.
1111690 if (c < 0)
58 c -= val / 2;
59 1111690 else c += (val/2);
60 1111690 }
61 1111957 c -= c % val;
62 1111957 coord = c;
63 1111957 }
64
65 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
66 {
67 return
68 (
69 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
70 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
71 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
72 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
73 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
74 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
75 );
76 }
77
78 namespace
79 {
80 int32_t trapConstantHorizontalID;
81 int32_t trapConstantVerticalID;
82 int32_t trapLOSHorizontalID;
83 int32_t trapLOSVerticalID;
84 int32_t trapLOS4WayID;
85
86 int32_t cornerTrapID;
87 int32_t centerTrapID;
88
89 int32_t rockID;
90 int32_t zoraID;
91 int32_t statueID;
92 }
93
94 372 void identifyCFEnemies()
95 {
96 372 trapConstantHorizontalID=-1;
97 372 trapConstantVerticalID=-1;
98 372 trapLOSHorizontalID=-1;
99 372 trapLOSVerticalID=-1;
100 372 trapLOS4WayID=-1;
101 372 cornerTrapID=-1;
102 372 centerTrapID=-1;
103 372 rockID=-1;
104 372 zoraID=-1;
105 372 statueID=-1;
106
107
2/2
✓ Branch 0 taken 190464 times.
✓ Branch 1 taken 372 times.
190836 for(int32_t i=0; i<eMAXGUYS; i++)
108 {
109
3/4
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 190097 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 367 times.
190464 if((guysbuf[i].flags2&guy_trph) && trapLOSHorizontalID==-1)
110 367 trapLOSHorizontalID=i;
111
4/4
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 190086 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags2&guy_trpv) && trapLOSVerticalID==-1)
112 372 trapLOSVerticalID=i;
113
3/4
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 190092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags2&guy_trp4) && trapLOS4WayID==-1)
114 372 trapLOS4WayID=i;
115
3/4
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 190092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags2&guy_trplr) && trapConstantHorizontalID==-1)
116 372 trapConstantHorizontalID=i;
117
3/4
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 190092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags2&guy_trpud) && trapConstantVerticalID==-1)
118 372 trapConstantVerticalID=i;
119
120
3/4
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 190092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags2&guy_trap) && cornerTrapID==-1)
121 372 cornerTrapID=i;
122
3/4
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 190092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags2&guy_trp2) && centerTrapID==-1)
123 372 centerTrapID=i;
124
125
3/4
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 190092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags2&guy_rock) && rockID==-1)
126 372 rockID=i;
127
4/4
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 190073 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 370 times.
190464 if((guysbuf[i].flags2&guy_zora) && zoraID==-1)
128 370 zoraID=i;
129
130
4/4
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 190033 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 372 times.
190464 if((guysbuf[i].flags2 & guy_fire) && statueID==-1)
131 372 statueID=i;
132 190464 }
133 372 }
134
135 32 int32_t random_layer_enemy()
136 {
137 32 int32_t cnt=count_layer_enemies();
138
139
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
140 {
141 return eNONE;
142 }
143
144 32 int32_t ret=zc_oldrand()%cnt;
145 32 cnt=0;
146
147
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
148 {
149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tmpscr->layermap[i]!=0)
150 {
151 32 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
152
153
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
154 {
155
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
156 {
157
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
158 {
159 32 return layerscreen->enemy[j];
160 }
161
162 108 ++cnt;
163 108 }
164 108 }
165 }
166 }
167
168 return eNONE;
169 32 }
170
171 49 int32_t count_layer_enemies()
172 {
173 49 int32_t cnt=0;
174
175
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
176 {
177
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if(tmpscr->layermap[i]!=0)
178 {
179 79 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
180
181
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
182 {
183
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
184 {
185 420 ++cnt;
186 420 }
187 790 }
188 79 }
189 294 }
190
191 49 return cnt;
192 }
193
194 211789 int32_t hero_on_wall()
195 {
196 211789 zfix lx = Hero.getX();
197 211789 zfix ly = Hero.getY();
198
199
200
201
4/4
✓ Branch 0 taken 189837 times.
✓ Branch 1 taken 21952 times.
✓ Branch 2 taken 8850 times.
✓ Branch 3 taken 180987 times.
211789 if(lx>=48 && lx<=192)
202 {
203
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 180756 times.
180987 if(ly==32) return up+1;
204
205
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 180473 times.
180756 if(ly==128) return down+1;
206 180473 }
207
208
4/4
✓ Branch 0 taken 194033 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21403 times.
✓ Branch 3 taken 172630 times.
211275 if(ly>=48 && ly<=112)
209 {
210
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 172407 times.
172630 if(lx==32) return left+1;
211
212
2/2
✓ Branch 0 taken 172303 times.
✓ Branch 1 taken 104 times.
172407 if(lx==208) return right+1;
213 172303 }
214
215 210948 return 0;
216 211789 }
217
218 765533 bool tooclose(int32_t x,int32_t y,int32_t d)
219 {
220
2/2
✓ Branch 0 taken 567824 times.
✓ Branch 1 taken 197709 times.
765533 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
221 }
222
223 3989892 bool enemy::overpit(enemy *e)
224 {
225 // This function (and shadow_overpit) has been broken since it was written, and only
226 // checked the same diagonal of the hitbox, over and over again. The bug is because both
227 // loops used the same variable name.
228 // Checking literally every pixel seems like overkill, so for now let's continue to
229 // do the single diagonal but just once. That's why the outer loop is commented out.
230
231 // for ( int32_t q = 0; q < hxsz; ++q )
232 {
233
2/2
✓ Branch 0 taken 36952798 times.
✓ Branch 1 taken 3970690 times.
40923488 for ( int32_t q = 0; q < hit_height; ++q )
234 {
235 //check every pixel of the hitbox
236
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 36933596 times.
36952798 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
237 {
238 //if the hitbox is over a pit, we can't land
239 19202 return true;
240 }
241 36933596 }
242 }
243 3970690 return false;
244 3989892 }
245
246 12250275 bool enemy::shadow_overpit(enemy *e)
247 {
248 // for ( int32_t q = 0; q < hxsz; ++q )
249 {
250
2/2
✓ Branch 0 taken 176046221 times.
✓ Branch 1 taken 12223814 times.
188270035 for ( int32_t q = 0; q < hit_height; ++q )
251 {
252 //check every pixel of the hitbox
253
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 176019760 times.
176046221 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
254 {
255 //if the hitbox is over a pit, we can't land
256 26461 return true;
257 }
258 176019760 }
259 }
260 12223814 return false;
261 12250275 }
262
263 // Returns true iff a combo type or flag precludes enemy movement.
264 7430873 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
265 {
266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7430873 times.
7430873 if(moveflags & move_ignore_blockflags) return false;
267 7430873 int32_t c = COMBOTYPE(dx,dy);
268
4/4
✓ Branch 0 taken 4890323 times.
✓ Branch 1 taken 2540550 times.
✓ Branch 2 taken 1398325 times.
✓ Branch 3 taken 1142225 times.
9971423 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
269
3/6
✓ Branch 0 taken 2522226 times.
✓ Branch 1 taken 4908647 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2522226 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7430873 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
270
5/6
✓ Branch 0 taken 2581772 times.
✓ Branch 1 taken 4849101 times.
✓ Branch 2 taken 2579895 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2579895 times.
✗ Branch 5 not taken.
14862510 return c==cPIT || c==cPITB || c==cPITC ||
271
4/6
✓ Branch 0 taken 2579895 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2579895 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2431147 times.
✓ Branch 5 taken 148748 times.
2579895 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
272 // Block enemies type and block enemies flags
273
2/2
✓ Branch 0 taken 2574619 times.
✓ Branch 1 taken 2425871 times.
148748 combo_class_buf[c].block_enemies&1 ||
274
4/4
✓ Branch 0 taken 2571949 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2571702 times.
✓ Branch 3 taken 247 times.
2574619 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
275
4/4
✓ Branch 0 taken 2570884 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2570818 times.
✓ Branch 3 taken 66 times.
2571702 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
276 // Check for ladder-only combos which aren't dried water
277
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2560192 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5141341 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
278 // Check for drownable water
279
4/4
✓ Branch 0 taken 572182 times.
✓ Branch 1 taken 1998341 times.
✓ Branch 2 taken 1900 times.
✓ Branch 3 taken 570282 times.
2570523 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
280 2584413 }
281
282 // Returns true iff enemy is floating and blocked by a combo type or flag.
283 8647530 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
284 {
285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8647530 times.
8647530 if(moveflags & move_ignore_blockflags) return false;
286
4/4
✓ Branch 0 taken 6549648 times.
✓ Branch 1 taken 2097882 times.
✓ Branch 2 taken 1749423 times.
✓ Branch 3 taken 348459 times.
10745412 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
287
3/4
✓ Branch 0 taken 6564155 times.
✓ Branch 1 taken 2083375 times.
✓ Branch 2 taken 2083375 times.
✗ Branch 3 not taken.
10730905 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
288
2/2
✓ Branch 0 taken 1200911 times.
✓ Branch 1 taken 7446619 times.
16094149 return ((special==spw_floater)&&
289
2/2
✓ Branch 0 taken 7436494 times.
✓ Branch 1 taken 10125 times.
7446619 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
290
2/2
✓ Branch 0 taken 7436375 times.
✓ Branch 1 taken 119 times.
7436494 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
291
2/2
✓ Branch 0 taken 7436204 times.
✓ Branch 1 taken 171 times.
7436375 (MAPFLAG(dx,dy)==mfNOENEMY)||
292
2/2
✓ Branch 0 taken 7435949 times.
✓ Branch 1 taken 255 times.
7436204 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
293
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6193420 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
14867894 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
294
2/2
✓ Branch 0 taken 6183831 times.
✓ Branch 1 taken 1248114 times.
7431945 (pit_blocks && ispitfall(dx,dy))));
295 8647530 }
296 // Returns true iff a combo type or flag precludes enemy movement.
297 268958 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
298 {
299 268958 int32_t c = COMBOTYPE(dx,dy);
300 268958 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
301
2/2
✓ Branch 0 taken 33457 times.
✓ Branch 1 taken 235501 times.
268958 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
302
5/6
✓ Branch 0 taken 268938 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 268821 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 268821 times.
✗ Branch 5 not taken.
1014723 return c==cPIT || c==cPITB || c==cPITC ||
303
4/6
✓ Branch 0 taken 268821 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268821 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239045 times.
✓ Branch 5 taken 29776 times.
268821 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
304 // Block enemies type and block enemies flags
305
2/2
✓ Branch 0 taken 268248 times.
✓ Branch 1 taken 238472 times.
29776 combo_class_buf[c].block_enemies&1 ||
306
4/4
✓ Branch 0 taken 267922 times.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 267891 times.
✓ Branch 3 taken 31 times.
268248 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
307
4/4
✓ Branch 0 taken 264391 times.
✓ Branch 1 taken 3500 times.
✓ Branch 2 taken 264116 times.
✓ Branch 3 taken 275 times.
267891 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
308 // Check for ladder-only combos which aren't dried water
309
4/4
✓ Branch 0 taken 1042 times.
✓ Branch 1 taken 263074 times.
✓ Branch 2 taken 1003 times.
✓ Branch 3 taken 39 times.
528193 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
310 // Check for drownable water
311
4/4
✓ Branch 0 taken 42399 times.
✓ Branch 1 taken 221678 times.
✓ Branch 2 taken 24004 times.
✓ Branch 3 taken 18395 times.
264077 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
312 }
313
314 // Returns true iff enemy is floating and blocked by a combo type or flag.
315 122271 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
316 {
317
2/2
✓ Branch 0 taken 119948 times.
✓ Branch 1 taken 2323 times.
122271 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
318 122271 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 122271 times.
244542 return ((special==spw_floater)&&
320
2/2
✓ Branch 0 taken 122174 times.
✓ Branch 1 taken 97 times.
122271 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
321
2/2
✓ Branch 0 taken 122169 times.
✓ Branch 1 taken 5 times.
122174 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
322
2/2
✓ Branch 0 taken 122160 times.
✓ Branch 1 taken 9 times.
122169 (MAPFLAG(dx,dy)==mfNOENEMY)||
323
2/2
✓ Branch 0 taken 122131 times.
✓ Branch 1 taken 29 times.
122160 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
324
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 119810 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
244012 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
325
2/2
✓ Branch 0 taken 119810 times.
✓ Branch 1 taken 2071 times.
121881 (pit_blocks && ispitfall(dx,dy))));
326 }
327
328
4/8
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114522 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114522 times.
✗ Branch 7 not taken.
229044 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
329 114522 {
330
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 x=X;
331
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 y=Y;
332 114522 id=Id;
333 114522 clk=Clk;
334
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 floor_y=y;
335 114522 ceiling=false;
336 114522 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
337 114522 grumble = movestatus = posframe = timer = ox = oy = 0;
338
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114522 times.
✓ Branch 2 taken 114522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114522 times.
✗ Branch 5 not taken.
114522 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
339 114522 did_armos=true;
340 114522 script_spawned=false;
341
342 114522 d = guysbuf + (id & 0xFFF);
343 114522 hp = d->hp;
344 114522 starting_hp = hp;
345 // cs = d->cset;
346 //d variables
347
348 114522 flags=d->flags;
349 114522 flags2=d->flags2;
350 114522 s_tile=d->s_tile; //secondary (additional) tile(s)
351 114522 family=d->family;
352 114522 dcset=d->cset;
353 114522 cs=dcset;
354
2/2
✓ Branch 0 taken 88397 times.
✓ Branch 1 taken 26125 times.
114522 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
355 114522 dp=d->dp;
356 114522 wdp=d->wdp;
357 114522 wpn=d->weapon;
358 114522 wpnsprite = d-> wpnsprite; //2.6 -Z
359 114522 rate=d->rate;
360 114522 hrate=d->hrate;
361
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 dstep=d->step;
362 114522 homing=d->homing;
363 114522 dmisc1=d->attributes[0];
364 114522 dmisc2=d->attributes[1];
365 114522 dmisc3=d->attributes[2];
366 114522 dmisc4=d->attributes[3];
367 114522 dmisc5=d->attributes[4];
368 114522 dmisc6=d->attributes[5];
369 114522 dmisc7=d->attributes[6];
370 114522 dmisc8=d->attributes[7];
371 114522 dmisc9=d->attributes[8];
372 114522 dmisc10=d->attributes[9];
373 114522 dmisc11=d->attributes[10];
374 114522 dmisc12=d->attributes[11];
375 114522 dmisc13=d->attributes[12];
376 114522 dmisc14=d->attributes[13];
377 114522 dmisc15=d->attributes[14];
378 114522 dmisc16=d->attributes[15];
379 114522 dmisc17=d->attributes[16];
380 114522 dmisc18=d->attributes[17];
381 114522 dmisc19=d->attributes[18];
382 114522 dmisc20=d->attributes[19];
383 114522 dmisc21=d->attributes[20];
384 114522 dmisc22=d->attributes[21];
385 114522 dmisc23=d->attributes[22];
386 114522 dmisc24=d->attributes[23];
387 114522 dmisc25=d->attributes[24];
388 114522 dmisc26=d->attributes[25];
389 114522 dmisc27=d->attributes[26];
390 114522 dmisc28=d->attributes[27];
391 114522 dmisc29=d->attributes[28];
392 114522 dmisc30=d->attributes[29];
393 114522 dmisc31=d->attributes[30];
394 114522 dmisc32=d->attributes[31];
395
2/2
✓ Branch 0 taken 4076 times.
✓ Branch 1 taken 110446 times.
114522 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
396 {
397 110446 dmisc31 = dmisc32;
398 110446 dmisc32 = 0;
399 110446 }
400 114522 spr_shadow=d->spr_shadow;
401 114522 spr_death=d->spr_death;
402 114522 spr_spawn=d->spr_spawn;
403
404
2/2
✓ Branch 0 taken 4695402 times.
✓ Branch 1 taken 114522 times.
4809924 for(int32_t i=0; i<edefLAST255; i++)
405 4695402 defense[i]=d->defense[i];
406
407 114522 bgsfx=d->bgsfx;
408 114522 hitsfx=d->hitsfx;
409 114522 deadsfx=d->deadsfx;
410 114522 bosspal=d->bosspal;
411 114522 parent_script_UID = 0;
412
413 114522 frozentile = d->frozentile;
414
415 114522 frozencset = d->frozencset;
416 114522 frozenclock = 0;
417
2/2
✓ Branch 0 taken 1145220 times.
✓ Branch 1 taken 114522 times.
1259742 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
418
419
2/2
✓ Branch 0 taken 1946874 times.
✓ Branch 1 taken 114522 times.
2061396 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
420 //firesfx = 0; //t.b.a -Z
421 114522 isCore = true; //t.b.a
422 114522 parentCore = 0; //t.b.a
423
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
424
425 114522 firesfx = d->firesfx;
426
2/2
✓ Branch 0 taken 3664704 times.
✓ Branch 1 taken 114522 times.
3779226 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
427
2/2
✓ Branch 0 taken 3664704 times.
✓ Branch 1 taken 114522 times.
3779226 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
428
429 114522 script = d->script;
430 114522 weaponscript = d->weaponscript;
431
432
2/2
✓ Branch 0 taken 916176 times.
✓ Branch 1 taken 114522 times.
1030698 for ( int32_t q = 0; q < 8; q++ )
433 {
434 916176 initD[q] = d->initD[q];
435 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
436 916176 weap_initiald[q] = d->weap_initiald[q];
437 916176 }
438
2/2
✓ Branch 0 taken 229044 times.
✓ Branch 1 taken 114522 times.
343566 for ( int32_t q = 0; q < 2; q++ )
439 {
440 229044 initA[q] = d->initA[q];
441 229044 weap_initiala[q] = d->weap_initiala[q];
442 229044 }
443
444 114522 stickclk = 0;
445 114522 submerged = false;
446 114522 didScriptThisFrame = false;
447 114522 ffcactivated = 0;
448 114522 hitdir = -1;
449 114522 dialogue_str = 0; //set by spawn flags.
450 114522 editorflags = d->editorflags; //set by Enemy Editor
451 //Set the drawing flag for this sprite.
452
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
453
454
455
2/2
✓ Branch 0 taken 8858 times.
✓ Branch 1 taken 105664 times.
114522 if(bosspal>-1)
456 {
457
1/2
✓ Branch 0 taken 8858 times.
✗ Branch 1 not taken.
8858 loadpalset(csBOSS,pSprite(bosspal));
458 8858 }
459
460
2/2
✓ Branch 0 taken 49811 times.
✓ Branch 1 taken 64711 times.
114522 if(bgsfx>-1)
461 {
462
1/2
✓ Branch 0 taken 49811 times.
✗ Branch 1 not taken.
49811 cont_sfx(bgsfx);
463 49811 }
464
465
2/2
✓ Branch 0 taken 88397 times.
✓ Branch 1 taken 26125 times.
114522 if(get_qr(qr_NEWENEMYTILES))
466 {
467 88397 o_tile=d->e_tile;
468 88397 frate = d->e_frate;
469 88397 }
470 else
471 {
472 26125 o_tile=d->tile;
473 26125 frate = d->frate;
474 }
475
476 114522 tile=0; //init to 0 here, but set it later.
477
478 114522 scripttile = -1;
479 114522 scriptflip = -1;
480 114522 do_animation = true;
481 114522 immortal = false;
482 114522 noSlide = false;
483 114522 deathexstate = -1;
484
485 114522 hashero=false;
486
487 // If they forgot the invisibility flag, here's another failsafe:
488
4/4
✓ Branch 0 taken 5791 times.
✓ Branch 1 taken 108731 times.
✓ Branch 2 taken 5697 times.
✓ Branch 3 taken 94 times.
114522 if(o_tile==0 && family!=eeSPINTILE)
489
1/2
✓ Branch 0 taken 5697 times.
✗ Branch 1 not taken.
5697 flags |= guy_invisible;
490
491 // step = d->step/100.0;
492 // To preserve the odd step values for Keese & Gleeok heads. -L
493
5/8
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12145 times.
✓ Branch 5 taken 102377 times.
✓ Branch 6 taken 12145 times.
✗ Branch 7 not taken.
114522 if(dstep==62.0) dstep+=0.5;
494
5/8
✓ Branch 0 taken 102377 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102377 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 101678 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
102377 else if(dstep==89) dstep-=1/9;
495
496
5/10
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114522 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114522 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 114522 times.
✗ Branch 9 not taken.
114522 step = zslongToFix(dstep*100);
497
498
499 114522 item_set = d->item_set;
500 114522 grumble = d->grumble;
501
502
2/2
✓ Branch 0 taken 89927 times.
✓ Branch 1 taken 24595 times.
114522 if(frate == 0)
503 24595 frate = 256;
504
505 114522 leader = itemguy = dying = scored = false;
506 114522 canfreeze = count_enemy = true;
507
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 mainguy = !(flags & guy_doesnt_count);
508
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 dir = zc_oldrand()&3;
509
510 //2.6 Enemy Editor Hit and TIle Sizes
511
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 114513 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
114522 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
512 // al_trace("Enemy txsz:%i\n", txsz);
513
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 114513 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
114522 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
514
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
114522 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
515
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 114515 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
114522 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
516
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114522 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
517
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
518
1/2
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
114522 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
519 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114522 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114522 times.
114522 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
522 {
523 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
524 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
525 }
526
527
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 114522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
114522 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
528
529 114522 SIZEflags = d->SIZEflags;
530
531
8/10
✓ Branch 0 taken 114273 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114156 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
114522 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
532 1 wpn = 0;
533
534 //tile should never be 0 after init --Z (failsafe)
535
4/6
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114522 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107959 times.
✓ Branch 5 taken 6563 times.
114522 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
536
537 //Moveflags; for gravity and pit interaction
538 114522 moveflags = d->moveflags;
539
3/4
✓ Branch 0 taken 114522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17660 times.
✓ Branch 3 taken 96862 times.
114522 if(!can_pitfall(false))
540 {
541 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
542
2/4
✓ Branch 0 taken 17660 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17660 times.
✗ Branch 3 not taken.
17660 moveflags &= ~move_can_pitfall;
543
2/4
✓ Branch 0 taken 17660 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17660 times.
✗ Branch 3 not taken.
17660 moveflags &= ~move_can_waterdrown;
544 17660 }
545
546 114522 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
547 114522 }
548
549 598 int32_t enemy::getScriptUID() { return script_UID; }
550 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
551 114290 enemy::~enemy()
552 114290 {
553
2/4
✓ Branch 0 taken 114290 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114290 times.
✗ Branch 3 not taken.
114290 FFCore.deallocateAllScriptOwned(ScriptType::NPC, getUID());
554
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 114277 times.
114290 if(hashero)
555 {
556
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 Hero.setEaten(0);
557 13 hashero=false;
558 13 }
559 114290 }
560
561 bool enemy::is_move_paused()
562 {
563 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
564 }
565
566 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
567 {
568 7024 int32_t yg = (special==spw_floater)?8:0;
569 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
570 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
571
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
572 input_x = dx;
573
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
574 input_y = dy;
575
576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & move_ignore_screenedge)
577
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
578
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (240+nb)) || ((input_y+hit_height-1) >= (160+nb))))
579 return true;
580
581
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
582 {
583 if(ispitfall(dx,dy))
584 return true;
585 }
586
587 7024 bool flying = false;
588 7024 bool cansolid = false;
589
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(moveflags & move_ignore_solidity)
590 cansolid = true;
591
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
592 {
593 case spw_clipbottomright:
594 if(dy>=128 || dx>=208) return true;
595 break;
596 case spw_clipright:
597 break; //if(input_x>=208) return true; break;
598
599 case spw_wizzrobe: // fall through
600 case spw_floater: // Special case for fliers and wizzrobes - hack!
601 {
602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon() && !(moveflags & move_ignore_screenedge))
603 {
604 if(dy < 32-yg || dy >= 144) return true;
605 if(dx < 32 || dx >= 224) return true;
606 }
607
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
608 return true;
609 317 cansolid = true;
610 317 flying = true;
611 }
612 317 }
613
614 7024 dx &= ~7;
615 7024 dy &= ~7;
616
617
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
618
619
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
620 return !(moveflags & move_ignore_screenedge);
621 //_walkflag code
622 mapscr *s1, *s2;
623 7024 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
624 7024 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
625
626 7024 int32_t cpos=(dx>>4)+(dy&0xF0);
627
3/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1038 times.
✓ Branch 3 taken 5986 times.
7024 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
628 7024 newcombo const& c = combobuf[ci];
629 7024 newcombo const& c1 = combobuf[ci1];
630 7024 newcombo const& c2 = combobuf[ci2];
631
632 7024 int32_t b=1;
633
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
634
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
635
636 #define iwtr(cmb, x, y, shallow) \
637 (shallow \
638 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
639 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
640 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
641 7024 bool wtr = iwtr(ci, dx, dy, false);
642
2/2
✓ Branch 0 taken 3551 times.
✓ Branch 1 taken 3473 times.
7024 bool shwtr = iwtr(ci, dx, dy, true);
643 7024 bool pit = ispitfall(dx,dy);
644
645
3/4
✓ Branch 0 taken 6934 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
7024 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
646
3/4
✓ Branch 0 taken 6934 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
7024 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
647 7024 bool needwtr = (moveflags & move_only_waterwalk);
648 7024 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
649 7024 bool needpit = (moveflags & move_only_pitwalk);
650
651
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
652 {
653 6707 int32_t cwalkflag = c.walk & 0xF;
654
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
656 {
657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
658 {
659 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
660 {
661 int efflag = (c1.walk & 0xF0)>>4;
662 int newsolid = (c1.walk & 0xF);
663 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
664 }
665 else cwalkflag &= c1.walk;
666 }
667 6707 else cwalkflag |= c1.walk & 0xF;
668 6707 }
669
2/2
✓ Branch 0 taken 5986 times.
✓ Branch 1 taken 721 times.
6707 if (s2)
670 {
671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 721 times.
721 if (c2.type == cBRIDGE)
672 {
673 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
674 {
675 int efflag = (c2.walk & 0xF0)>>4;
676 int newsolid = (c2.walk & 0xF);
677 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
678 }
679 else cwalkflag &= c2.walk;
680 }
681 721 else cwalkflag |= c2.walk & 0xF;
682 721 }
683
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
684 239 return true;
685 6468 }
686
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
687 {
688 bool ret = true;
689 if (needwtr && wtr) ret = false;
690 else if (needshwtr && shwtr) ret = false;
691 else if (needpit && pit) ret = false;
692 return ret;
693 }
694
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
695 return true;
696
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
697 return true;
698
699 6785 return false;
700 7024 }
701
702 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
703 {
704
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
705 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
706 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
707
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
708 {
709 if((moveflags & move_obeys_grav) && isSideViewGravity())
710 return false;
711 }
712
713
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
714
715
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
716 {
717
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
718 {
719
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
720 770 int mx = (bx+dx).getFloor();
721
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
722 {
723
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
724 return false;
725 2976 }
726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
727 return false;
728
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
729 return false;
730 770 }
731 else
732 {
733 341 int mx = (rx+dx).getCeil();
734 341 int lx = mx-hit_width+1;
735
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
736 {
737
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
738 1 return false;
739 2141 }
740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
741 return false;
742
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
743 return false;
744 }
745 1110 }
746
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
747 {
748
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
749 {
750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
751 315 int my = (by+dy).getFloor();
752
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
753 {
754
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
755 238 return false;
756 154 }
757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
758 return false;
759
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
760 return false;
761 77 }
762 else
763 {
764 109 int my = (ry+dy).getCeil();
765 109 int ly = my-hit_height+1;
766
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
767 {
768
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
769 return false;
770 218 }
771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
772 return false;
773
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
774 return false;
775 }
776 186 }
777 else //! Untested, and currently unused.
778 {
779 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
780 }
781 1296 return true;
782 1535 }
783
784 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
785 {
786 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
787 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
788
789 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
790
791 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
792 return false;
793 for(zfix ty = 0; by+ty < ry; ty += 8)
794 {
795 for(zfix tx = 0; bx+tx < rx; tx += 8)
796 {
797 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
798 return false;
799 }
800 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
801 return false;
802 }
803 for(zfix tx = 0; bx+tx < rx; tx += 8)
804 {
805 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
806 return false;
807 }
808 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
809 return false;
810 return true;
811 }
812
813 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
814 {
815 auto oxsz = hit_width, oysz = hit_height;
816 if(nwid > -1) hit_width = nwid;
817 if(nhei > -1) hit_height = nhei;
818 bool ret = scr_canplace(dx,dy,special,kb);
819 hit_width = oxsz; hit_height = oysz;
820 return ret;
821 }
822
823 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
824 {
825 1311 bool ret = true;
826
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
827 dy = 0;
828 1311 const int scl = 2;
829
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
830 {
831
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
832 {
833 260 int32_t tdx = dx.sign() * scl;
834
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
835 260 dx -= tdx;
836 else
837 {
838 if(earlyret) return false;
839 dx = tdx;
840 ret = false;
841 }
842 260 }
843 else
844 {
845 34 int32_t tdy = dy.sign() * scl;
846
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
847 27 dy -= tdy;
848 else
849 {
850
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
851 7 dy = tdy;
852 7 ret = false;
853 }
854 }
855 }
856
857
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
858 {
859
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
860 1110 x += dx;
861 else
862 {
863
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
864 ret = false;
865 int xsign = dx.sign();
866 while(scr_canmove(xsign, 0, special, kb, ign_sv))
867 {
868 x += xsign;
869 dx -= xsign;
870 }
871 if(dx)
872 {
873 dx.doDecBound(0,-9999, 0,9999);
874 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
875 if(scr_canmove(val, 0, special, kb, ign_sv))
876 {
877 retval = val;
878 return BSEARCH_CONTINUE_AWAY0;
879 }
880 else return BSEARCH_CONTINUE_TOWARD0;
881 });
882 x += dx;
883 }
884 }
885 1110 }
886
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
887 {
888
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
889 186 y += dy;
890 else
891 {
892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
893 14 ret = false;
894 14 int ysign = dy.sign();
895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
896 {
897 y += ysign;
898 dy -= ysign;
899 }
900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
901 {
902 14 dy.doDecBound(0,-9999, 0,9999);
903
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
905 {
906 retval = val;
907 return BSEARCH_CONTINUE_AWAY0;
908 }
909 210 else return BSEARCH_CONTINUE_TOWARD0;
910 210 });
911 14 y += dy;
912 14 }
913 }
914 200 }
915 1310 return ret;
916 1311 }
917
918 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
919 {
920
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
921
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
922 {
923 case up:
924 return movexy(0, -px, special, kb, false, earlyret);
925 case down:
926 16 return movexy(0, px, special, kb, false, earlyret);
927 case left:
928 479 return movexy(-px, 0, special, kb, false, earlyret);
929 case right:
930 259 return movexy(px, 0, special, kb, false, earlyret);
931 case r_up:
932 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
933 case r_down:
934 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
935 case l_up:
936 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
937 case l_down:
938 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
939 }
940 return false;
941 754 }
942
943 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
944 {
945 double v = degrees.getFloat() * PI / 180.0;
946 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
947 return movexy(dx, dy, special, kb, false, earlyret);
948 }
949
950 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
951 {
952 zfix tx = x, ty = y;
953 bool ret = movexy(dx, dy, special, kb, false, true);
954 x = tx;
955 y = ty;
956 return ret;
957 }
958 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
959 {
960 754 zfix tx = x, ty = y;
961 754 bool ret = moveDir(dir, px, special, kb, true);
962 754 x = tx;
963 754 y = ty;
964 754 return ret;
965 }
966 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
967 {
968 zfix tx = x, ty = y;
969 bool ret = moveAtAngle(degrees, px, special, kb, true);
970 x = tx;
971 y = ty;
972 return ret;
973 }
974
975 // Handle pitfalls
976 37826557 bool enemy::do_falling(int32_t index)
977 {
978
2/2
✓ Branch 0 taken 37824259 times.
✓ Branch 1 taken 2298 times.
37826557 if(fallclk > 0)
979 {
980
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2265 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 20 times.
2298 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
981
2/2
✓ Branch 0 taken 2276 times.
✓ Branch 1 taken 22 times.
2298 if(!--fallclk)
982 {
983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
984 ++fallclk; //force another frame of falling.... forever.
985
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
986 {
987
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_never_return)
988 never_return(index);
989
990
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
991 kill_em_all();
992
993 //leave_item(); //Don't drop items in pits!
994 11 stop_bgsfx(index);
995 11 return true;
996 }
997 else
998 {
999 11 try_death(true); //Force death
1000 11 ++fallclk; //force another frame of falling
1001 }
1002 11 }
1003
1004 2287 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1005 2287 cs = spr.csets & 0xF;
1006
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 int32_t fr = spr.frames ? spr.frames : 1;
1007
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 int32_t spd = spr.speed ? spr.speed : 1;
1008 2287 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1009
2/2
✓ Branch 0 taken 1101 times.
✓ Branch 1 taken 1186 times.
2287 tile = spr.tile + zc_min(animclk / spd, fr-1);
1010 2287 }
1011 37826546 return false;
1012 37826557 }
1013
1014 // Handle drowning in water
1015 37824259 bool enemy::do_drowning(int32_t index)
1016 {
1017
1/2
✓ Branch 0 taken 37824259 times.
✗ Branch 1 not taken.
37824259 if(drownclk > 0)
1018 {
1019 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1020 //!TODO: Drown SFX
1021 if(!--drownclk)
1022 {
1023 if(immortal) //Keep alive forever
1024 ++drownclk; //force another frame of falling.... forever.
1025 else if(dying) //Give 1 frame for script revival
1026 {
1027 if(flags&guy_never_return)
1028 never_return(index);
1029
1030 if(leader)
1031 kill_em_all();
1032
1033 //leave_item(); //Don't drop items in pits!
1034 stop_bgsfx(index);
1035 return true;
1036 }
1037 else
1038 {
1039 try_death(true); //Force death
1040 ++drownclk; //force another frame of falling
1041 }
1042 }
1043
1044 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
1045 {
1046 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
1047 cs = spr.csets & 0xF;
1048 int32_t fr = spr.frames ? spr.frames : 1;
1049 int32_t spd = spr.speed ? spr.speed : 1;
1050 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1051 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1052 }
1053 else
1054 {
1055 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
1056 cs = spr.csets & 0xF;
1057 int32_t fr = spr.frames ? spr.frames : 1;
1058 int32_t spd = spr.speed ? spr.speed : 1;
1059 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1060 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1061 }
1062 }
1063 37824259 return false;
1064 37824259 }
1065
1066 // Supplemental animation code that all derived classes should call
1067 // as a return value for animate().
1068 // Handles the death animation and returns true when enemy is finished.
1069 38488847 bool enemy::Dead(int32_t index)
1070 {
1071
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38487018 times.
38488847 if(immortal)
1072 {
1073 1829 dying = false;
1074 1829 return false;
1075 }
1076
2/2
✓ Branch 0 taken 763084 times.
✓ Branch 1 taken 37723934 times.
38487018 if(dying)
1077 {
1078
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 763083 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
763084 if(deathexstate > -1 && deathexstate < 32)
1079 {
1080 1 setxmapflag(1<<deathexstate);
1081 1 deathexstate = -1;
1082 1 }
1083 763084 --clk2;
1084
1085
4/4
✓ Branch 0 taken 723458 times.
✓ Branch 1 taken 39626 times.
✓ Branch 2 taken 38640 times.
✓ Branch 3 taken 3195 times.
763084 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1086
2/2
✓ Branch 0 taken 41835 times.
✓ Branch 1 taken 681623 times.
723458 && hp>-1000) // not killed by ringleader
1087 38640 death_sfx();
1088
1089
2/2
✓ Branch 0 taken 719703 times.
✓ Branch 1 taken 43381 times.
763084 if(clk2==0)
1090 {
1091
2/2
✓ Branch 0 taken 42677 times.
✓ Branch 1 taken 704 times.
43381 if(flags&guy_never_return)
1092 704 never_return(index);
1093
1094
2/2
✓ Branch 0 taken 43310 times.
✓ Branch 1 taken 71 times.
43381 if(leader)
1095 71 kill_em_all();
1096
1097 43381 leave_item();
1098 43381 }
1099
1100 763084 stop_bgsfx(index);
1101 763084 return (clk2==0);
1102 }
1103
1104 37723934 return false;
1105 38488847 }
1106
1107 // Basic animation code that all derived classes should call.
1108 // The one with an index is the one that is called by
1109 // the guys sprite list; index is the enemy's index in the list.
1110 37826813 bool enemy::animate(int32_t index)
1111 {
1112
2/2
✓ Branch 0 taken 1683478 times.
✓ Branch 1 taken 36143335 times.
37826813 if(sclk <= 0) hitdir = -1;
1113
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 37826557 times.
37826813 if(switch_hooked)
1114 {
1115
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1116 {
1117 //Run its script
1118 if (!didScriptThisFrame)
1119 {
1120 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1121 {
1122 return 0; //Avoid NULLPO if this object deleted itself
1123 }
1124 }
1125 }
1126 256 return false;
1127 }
1128
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 37826546 times.
37826557 if(do_falling(index)) return true;
1129
2/2
✓ Branch 0 taken 2287 times.
✓ Branch 1 taken 37824259 times.
37826546 else if(fallclk)
1130 {
1131 //clks
1132
2/2
✓ Branch 0 taken 1611 times.
✓ Branch 1 taken 676 times.
2287 if(hclk>0)
1133 676 --hclk;
1134
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if(stunclk>0)
1135 --stunclk;
1136
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if ( frozenclock > 0 )
1137 --frozenclock;
1138
1/2
✓ Branch 0 taken 2287 times.
✗ Branch 1 not taken.
2287 if(hashero)
1139 {
1140 Hero.setX(x);
1141 Hero.setY(y);
1142 Hero.fallCombo = fallCombo;
1143 Hero.fallclk = fallclk;
1144 hashero = false; //Let Hero go if falling
1145 }
1146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2287 times.
2287 if (!didScriptThisFrame)
1147 {
1148 2287 run_script(MODE_NORMAL);
1149 2287 }
1150 2287 return false;
1151 }
1152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37824259 times.
37824259 if(do_drowning(index)) return true;
1153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37824259 times.
37824259 else if(drownclk)
1154 {
1155 //clks
1156 if(hclk>0)
1157 --hclk;
1158 if(stunclk>0)
1159 --stunclk;
1160 if ( frozenclock > 0 )
1161 --frozenclock;
1162 if(hashero)
1163 {
1164 Hero.setX(x);
1165 Hero.setY(y);
1166 Hero.drownclk = drownclk;
1167 hashero = false; //Let Hero go if falling
1168 }
1169 if (!didScriptThisFrame)
1170 {
1171 run_script(MODE_NORMAL);
1172 }
1173 return false;
1174 }
1175 37824259 int32_t nx = real_x(x);
1176 37824259 int32_t ny = real_y(y);
1177
1178
4/4
✓ Branch 0 taken 27356867 times.
✓ Branch 1 taken 10467392 times.
✓ Branch 2 taken 5644011 times.
✓ Branch 3 taken 21712856 times.
37824259 if(ox!=nx || oy!=ny)
1179 {
1180 16111403 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1181 16111403 }
1182
1183 37824259 ox = nx;
1184 37824259 oy = ny;
1185
1186 // Maybe they fell off the bottom in sideview, or were moved by a script.
1187
1188 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1189
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 37822430 times.
37824259 if ( immortal )
1190 {
1191 //skip, as it can go out of bounds, from immortality
1192 1829 }
1193
2/6
✓ Branch 0 taken 37822430 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37822430 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37822430 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1194 {
1195 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1196 }
1197
9/10
✓ Branch 0 taken 37426337 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 37821425 times.
✓ Branch 3 taken 1005 times.
✓ Branch 4 taken 37791401 times.
✓ Branch 5 taken 30024 times.
✓ Branch 6 taken 37791401 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 51 times.
✓ Branch 9 taken 37791350 times.
37822430 else if ( (OUTOFBOUNDS) )
1198 {
1199 31080 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1200 31080 }
1201 //fall down
1202
6/6
✓ Branch 0 taken 27135246 times.
✓ Branch 1 taken 10689013 times.
✓ Branch 2 taken 10421486 times.
✓ Branch 3 taken 27402773 times.
✓ Branch 4 taken 506382 times.
✓ Branch 5 taken 9915104 times.
37824259 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1203 {
1204
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 9611530 times.
9915104 if(isSideViewGravity())
1205 {
1206
1/2
✓ Branch 0 taken 303574 times.
✗ Branch 1 not taken.
303574 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1207 {
1208
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
1209 {
1210 127235 bool willHitSVPlatform = false;
1211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH)?hit_width:16;
1212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT)?hit_height:16;
1213
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1214 {
1215
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1216 {
1217 willHitSVPlatform = true;
1218 break;
1219 }
1220 127235 }
1221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
1222 {
1223 y+=fall/100;
1224 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1225 do_fix(y, 16); //Fix to top of SV Ladder
1226 fall = 0;
1227 }
1228 else
1229 {
1230 127235 y+=fall/100;
1231
2/2
✓ Branch 0 taken 17808 times.
✓ Branch 1 taken 109427 times.
127235 if(fall <= (int32_t)zinit.terminalv)
1232 109427 fall += (zinit.gravity/100);
1233 }
1234 127235 }
1235 else
1236 {
1237
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 176072 times.
176339 if(fall!=0) // Only fix pos once
1238 {
1239 //y-=(int32_t)y%8; // Fix position
1240 267 do_fix(y, 8); //Fix position
1241 267 }
1242
1243 176339 fall = 0;
1244 }
1245 303574 }
1246 else
1247 {
1248 if(isOnSideviewPlatform())
1249 fall = 0;
1250 else
1251 {
1252 zfix fall_amnt = fall/100;
1253 bool hit = false;
1254 while(fall_amnt >= 1)
1255 {
1256 --fall_amnt;
1257 ++y;
1258 if(isOnSideviewPlatform())
1259 {
1260 y = y.getInt();
1261 fall_amnt = 0;
1262 hit = true;
1263 break;
1264 }
1265 }
1266 if(fall_amnt > 0)
1267 y += fall_amnt;
1268 if(fall_amnt < 0)
1269 {
1270 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1271 hit = true;
1272 }
1273 if(hit)
1274 fall = 0;
1275 else if(fall <= (int32_t)zinit.terminalv)
1276 fall += (zinit.gravity/100);
1277 }
1278 }
1279 303574 }
1280 else
1281 {
1282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9611530 times.
9611530 if (!(moveflags & move_no_fake_z))
1283 {
1284
2/2
✓ Branch 0 taken 5058628 times.
✓ Branch 1 taken 4552902 times.
9611530 if(fakefall!=0)
1285 4552902 fakez-=(fakefall/100);
1286
1287
2/2
✓ Branch 0 taken 4552902 times.
✓ Branch 1 taken 5058628 times.
9611530 if(fakez<0)
1288 4552902 fakez = fakefall = 0;
1289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5058628 times.
5058628 else if(fakefall <= (int32_t)zinit.terminalv)
1290 5058628 fakefall += (zinit.gravity/100);
1291
1292
5/6
✓ Branch 0 taken 9611530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5058628 times.
✓ Branch 3 taken 4552902 times.
✓ Branch 4 taken 4567130 times.
✓ Branch 5 taken 491498 times.
9611530 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1293 9611530 }
1294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9611530 times.
9611530 if (!(moveflags & move_no_real_z))
1295 {
1296
2/2
✓ Branch 0 taken 5479665 times.
✓ Branch 1 taken 4131865 times.
9611530 if(fall!=0)
1297 4131865 z-=(fall/100);
1298
1299
2/2
✓ Branch 0 taken 4118583 times.
✓ Branch 1 taken 5492947 times.
9611530 if(z<0)
1300 4118583 z = fall = 0;
1301
2/2
✓ Branch 0 taken 9167 times.
✓ Branch 1 taken 5483780 times.
5492947 else if(fall <= (int32_t)zinit.terminalv)
1302 5483780 fall += (zinit.gravity/100);
1303
1304
6/6
✓ Branch 0 taken 9570626 times.
✓ Branch 1 taken 40904 times.
✓ Branch 2 taken 5452043 times.
✓ Branch 3 taken 4118583 times.
✓ Branch 4 taken 4962352 times.
✓ Branch 5 taken 489691 times.
9611530 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1305 9611530 }
1306
1307 }
1308 9915104 }
1309
4/4
✓ Branch 0 taken 37428166 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 9195313 times.
✓ Branch 3 taken 28232853 times.
37824259 if(!isSideViewGravity() && (moveflags & move_can_pitfall))
1310 {
1311
8/10
✓ Branch 0 taken 9168816 times.
✓ Branch 1 taken 26497 times.
✓ Branch 2 taken 9129158 times.
✓ Branch 3 taken 39658 times.
✓ Branch 4 taken 9129158 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9168816 times.
✓ Branch 8 taken 9129158 times.
✓ Branch 9 taken 9129158 times.
9195313 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1312 {
1313 9129158 fallCombo = check_pits();
1314 9129158 }
1315 27453629 }
1316
4/4
✓ Branch 0 taken 37428166 times.
✓ Branch 1 taken 18654409 times.
✓ Branch 2 taken 146615 times.
✓ Branch 3 taken 37281551 times.
56082575 if(!isSideViewGravity() && (moveflags & move_can_waterdrown))
1317 {
1318
8/10
✓ Branch 0 taken 142669 times.
✓ Branch 1 taken 3946 times.
✓ Branch 2 taken 141616 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 141616 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 142669 times.
✓ Branch 8 taken 141616 times.
✓ Branch 9 taken 141616 times.
146615 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1319 {
1320 141616 drownCombo = check_water();
1321 141616 }
1322 429847 }
1323
1324 56365807 runKnockback(); //scripted knockback handling
1325
1326 // clk is incremented here
1327
2/2
✓ Branch 0 taken 54061115 times.
✓ Branch 1 taken 2304692 times.
56365807 if(++clk >= frate)
1328 2304692 clk=0;
1329
1330 // hit and death handling
1331
2/2
✓ Branch 0 taken 1240477 times.
✓ Branch 1 taken 55125330 times.
56365807 if(hclk>0)
1332 1240477 --hclk;
1333
1334
2/2
✓ Branch 0 taken 676316 times.
✓ Branch 1 taken 55689491 times.
56365807 if(stunclk>0)
1335 676316 --stunclk;
1336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56365807 times.
56365807 if ( frozenclock > 0 )
1337 --frozenclock;
1338
1339
5/6
✓ Branch 0 taken 13488 times.
✓ Branch 1 taken 56352319 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 13382 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
56365807 if(ceiling && z <= 0 && fakez <= 0)
1340 106 ceiling = false;
1341
1342 56365807 try_death();
1343
1344 56365807 scored=false;
1345
1346 56365807 ++c_clk;
1347
1348 //Run its script
1349
2/2
✓ Branch 0 taken 18566365 times.
✓ Branch 1 taken 37799442 times.
56365807 if (!didScriptThisFrame)
1350 {
1351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37799442 times.
37799442 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1352 {
1353 return 0; //Avoid NULLPO if this object deleted itself
1354 }
1355 37799442 }
1356
1357 // returns true when enemy is defeated
1358 56365807 return Dead(index);
1359 56368361 }
1360
1361 38578693 bool enemy::setSolid(bool set)
1362 {
1363
1/2
✓ Branch 0 taken 38578693 times.
✗ Branch 1 not taken.
38578693 bool actual = set && !isSubmerged();
1364 38578693 bool ret = solid_object::setSolid(actual);
1365 38578693 solid = set;
1366 38578693 return ret;
1367 }
1368 void enemy::doContactDamage(int32_t hdir)
1369 {
1370 Hero.hithero(guys.find(this), hdir);
1371 }
1372
1373 22405 void enemy::solid_push(solid_object *obj)
1374 {
1375
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&move_not_pushable) return; //not pushable
1377 22405 zfix dx, dy;
1378 22405 int32_t hdir = -1;
1379 22405 solid_push_int(obj,dx,dy,hdir,true);
1380
1381
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 22142 times.
22405 if(!dx && !dy) return;
1382
1383 263 bool t = obj->getTempNonsolid();
1384 263 obj->setTempNonsolid(true);
1385
1386 263 int32_t ydir = dy > 0 ? down : up;
1387 263 int32_t xdir = dx > 0 ? right : left;
1388
1389 263 auto special = isflier(id) ? spw_floater : spw_none;
1390
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1391 {
1392 //Crushed?
1393 7 }
1394
1395 263 obj->setTempNonsolid(t);
1396 22405 }
1397 22405 bool enemy::is_unpushable() const
1398 {
1399 22405 return isSubmerged();
1400 }
1401 22087 bool enemy::sideview_mode() const
1402 {
1403
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1404 }
1405
1406 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1407 {
1408 3234 int32_t yg = (special==spw_floater)?8:0;
1409 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1410
1411
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1412 4732 return true;
1413
1414 3238 bool isInDungeon = isdungeon();
1415
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1416 {
1417
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1418 1199 return true;
1419
1420
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1421
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1422 return true;
1423 595 }
1424
1425
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1426 {
1427
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1428
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1429 return true;
1430 62 }
1431
1432
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1433 {
1434 case spw_clipbottomright:
1435 if(dy>=128 || dx>=208) return true;
1436 break;
1437 case spw_clipright:
1438 break; //if(x>=208) return true; break;
1439
1440 case spw_wizzrobe: // fall through
1441 case spw_floater: // Special case for fliers and wizzrobes - hack!
1442 {
1443
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1444 {
1445
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1446
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1447 595 }
1448 857 return false;
1449 }
1450 }
1451
1452 dx&=(special==spw_halfstep)?(~7):(~15);
1453 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1454
1455 if(special==spw_water)
1456 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1457
1458 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1459 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1460 870 }
1461
1462 6575 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1463 {
1464 6575 bool kb = false;
1465 6575 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1466
1467
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6575 times.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6575 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6575 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6575 times.
6575 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
1468 return true;
1469
1470
2/2
✓ Branch 0 taken 5062 times.
✓ Branch 1 taken 1513 times.
6575 if(isdungeon())
1471 {
1472
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=144))
1473 return true;
1474
1475
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=224))
1476 return true;
1477 1513 }
1478
1479
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
6575 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1480 {
1481
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6575 times.
13150 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1482
2/4
✓ Branch 0 taken 6575 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6575 times.
✗ Branch 3 not taken.
6575 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1483 return true;
1484 6575 }
1485
1486
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 30 times.
6575 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1487 {
1488
3/4
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2657 times.
✗ Branch 3 not taken.
9202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2657 times.
2657 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1490 }
1491 else
1492 {
1493
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1494
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1495
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1497 }
1498 6575 }
1499
1500 32455765 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1501 {
1502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32455765 times.
32455765 if(moveflags & move_new_movement)
1503 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1504 32455765 int32_t yg = (special==spw_floater)?8:0;
1505 32455765 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1506
2/2
✓ Branch 0 taken 3703972 times.
✓ Branch 1 taken 28751793 times.
32455765 switch(dir)
1507 {
1508 case l_down:
1509 case r_down:
1510 case down:
1511 case 11: //r_down
1512 case 12: //down
1513 case 13: //l_down
1514 {
1515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3703972 times.
3703972 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1516 {
1517
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3703964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3703972 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT && !isflier(id) )
1518 {
1519 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1520
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1521 8 }
1522 3703972 }
1523 3703972 break;
1524 }
1525 }
1526
2/2
✓ Branch 0 taken 3704791 times.
✓ Branch 1 taken 28750974 times.
32455765 switch(dir)
1527 {
1528 case r_up:
1529 case r_down:
1530 case right:
1531 case 9: //r_up
1532 case 10: //right
1533 case 11: //r_down
1534 {
1535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3704791 times.
3704791 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1536 {
1537
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3704788 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3704791 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH && !isflier(id) )
1538 {
1539 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1540
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1541 3 }
1542 3704791 }
1543 3704791 break;
1544 }
1545 }
1546 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
1547
1548
10/10
✓ Branch 0 taken 22401718 times.
✓ Branch 1 taken 10054047 times.
✓ Branch 2 taken 8752429 times.
✓ Branch 3 taken 1301618 times.
✓ Branch 4 taken 10016968 times.
✓ Branch 5 taken 37079 times.
✓ Branch 6 taken 9993841 times.
✓ Branch 7 taken 23127 times.
✓ Branch 8 taken 22454590 times.
✓ Branch 9 taken 32448431 times.
32455765 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1549 44916514 return true;
1550
1551 32448431 bool isInDungeon = isdungeon();
1552
4/4
✓ Branch 0 taken 3927169 times.
✓ Branch 1 taken 28521262 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 3915413 times.
32448431 if(isInDungeon || special==spw_wizzrobe)
1553 {
1554
8/8
✓ Branch 0 taken 5892093 times.
✓ Branch 1 taken 22640925 times.
✓ Branch 2 taken 5667626 times.
✓ Branch 3 taken 224467 times.
✓ Branch 4 taken 5820209 times.
✓ Branch 5 taken 17045183 times.
✓ Branch 6 taken 5820022 times.
✓ Branch 7 taken 187 times.
28533018 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
1555 11487648 return true;
1556
1557
8/8
✓ Branch 0 taken 5739730 times.
✓ Branch 1 taken 11305640 times.
✓ Branch 2 taken 5573275 times.
✓ Branch 3 taken 166455 times.
✓ Branch 4 taken 5688191 times.
✓ Branch 5 taken 5783904 times.
✓ Branch 6 taken 5687237 times.
✓ Branch 7 taken 954 times.
17045370 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
1558
2/2
✓ Branch 0 taken 113868 times.
✓ Branch 1 taken 94 times.
11260512 if(special!=spw_door) // walk in door way
1559 113868 return true;
1560 5784952 }
1561
1562
6/6
✓ Branch 0 taken 3100399 times.
✓ Branch 1 taken 6599966 times.
✓ Branch 2 taken 750062 times.
✓ Branch 3 taken 2350337 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 698832 times.
9700365 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1563 {
1564
4/4
✓ Branch 0 taken 3042752 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3041800 times.
6091019 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1565
4/4
✓ Branch 0 taken 3042569 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3041850 times.
✓ Branch 3 taken 719 times.
3042752 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1566 7369 return true;
1567 3041800 }
1568
1569
4/4
✓ Branch 0 taken 7508153 times.
✓ Branch 1 taken 2178589 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9692996 switch(special)
1570 {
1571 case spw_clipbottomright:
1572
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=128 || dx>=208) return true;
1573 707 break;
1574 case spw_clipright:
1575 5281 break; //if(input_x>=208) return true; break;
1576
1577 case spw_wizzrobe: // fall through
1578 case spw_floater: // Special case for fliers and wizzrobes - hack!
1579 {
1580
2/2
✓ Branch 0 taken 2866474 times.
✓ Branch 1 taken 4641679 times.
7508153 if(isInDungeon)
1581 {
1582
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= 144) return true;
1583
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= 224) return true;
1584 4639539 }
1585 7506013 return false;
1586 }
1587 }
1588
1589 2184577 dx&=(special==spw_halfstep)?(~7):(~15);
1590
2/2
✓ Branch 0 taken 486587 times.
✓ Branch 1 taken 1697990 times.
2184577 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1591
1592
2/2
✓ Branch 0 taken 414391 times.
✓ Branch 1 taken 1770186 times.
2184577 if(special==spw_water)
1593
2/2
✓ Branch 0 taken 16741 times.
✓ Branch 1 taken 397650 times.
414391 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1594
1595
2/2
✓ Branch 0 taken 1711259 times.
✓ Branch 1 taken 58927 times.
1770186 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1596 {
1597
4/4
✓ Branch 0 taken 1227868 times.
✓ Branch 1 taken 483391 times.
✓ Branch 2 taken 1217831 times.
✓ Branch 3 taken 10037 times.
2929090 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1598
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1203251 times.
1217831 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1599 }
1600 else
1601 {
1602
4/4
✓ Branch 0 taken 42434 times.
✓ Branch 1 taken 16493 times.
✓ Branch 2 taken 42170 times.
✓ Branch 3 taken 264 times.
101097 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1603
3/4
✓ Branch 0 taken 41807 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 41807 times.
✗ Branch 3 not taken.
42170 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1604
4/4
✓ Branch 0 taken 36572 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 36557 times.
✓ Branch 3 taken 15 times.
41807 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1605
2/2
✓ Branch 0 taken 36254 times.
✓ Branch 1 taken 303 times.
36557 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1606 }
1607 10079707 }
1608
1609 383430 bool enemy::isOnSideviewPlatform()
1610 {
1611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
1612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1613
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
383430 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1614 return false;
1615
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 373124 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
383430 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
1616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383219 times.
383219 if(check_slope(x, y+1, usewid, usehei)) return true;
1617
2/2
✓ Branch 0 taken 383219 times.
✓ Branch 1 taken 168001 times.
551220 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1618 {
1619
2/2
✓ Branch 0 taken 168001 times.
✓ Branch 1 taken 215218 times.
383219 if(_walkflag(nx,y+usehei,1)) return true;
1620
3/4
✓ Branch 0 taken 168001 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120644 times.
✓ Branch 3 taken 47357 times.
168001 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47357 times.
47357 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1622 47357 }
1623 168001 return false;
1624 383430 }
1625
1626 // Stops playing the given sound only if there are no enemies left to play it
1627 765995 void enemy::stop_bgsfx(int32_t index)
1628 {
1629
2/2
✓ Branch 0 taken 750885 times.
✓ Branch 1 taken 15110 times.
765995 if(bgsfx<=0)
1630 750885 return;
1631
1632 // Look for other enemies with the same bgsfx
1633
2/2
✓ Branch 0 taken 52994 times.
✓ Branch 1 taken 8806 times.
61800 for(int32_t i=0; i<guys.Count(); i++)
1634 {
1635
4/4
✓ Branch 0 taken 41902 times.
✓ Branch 1 taken 11092 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35598 times.
52994 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1636 6304 return;
1637 46690 }
1638
1639 8806 stop_sfx(bgsfx);
1640 765995 }
1641
1642
1643 // to allow for different sfx on defeating enemy
1644 40248 void enemy::death_sfx()
1645 {
1646
2/2
✓ Branch 0 taken 39964 times.
✓ Branch 1 taken 284 times.
40248 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1647 40248 }
1648
1649 void enemy::move(zfix dx,zfix dy)
1650 {
1651 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1652 {
1653 switch(family)
1654 {
1655 case eeFIRE:
1656 case eeOTHER:
1657 return;
1658 default: break;
1659 }
1660 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1661 }
1662 */
1663 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1664 {
1665 x+=dx;
1666 y+=dy;
1667 }
1668 }
1669
1670 18327343 void enemy::move(zfix s)
1671 {
1672 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1673 {
1674 switch(family)
1675 {
1676 case eeFIRE:
1677 case eeOTHER:
1678 return;
1679 default: break;
1680 }
1681 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1682 }*/
1683
9/10
✓ Branch 0 taken 18327304 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 79762 times.
✓ Branch 3 taken 18247542 times.
✓ Branch 4 taken 40724 times.
✓ Branch 5 taken 39038 times.
✓ Branch 6 taken 855 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 855 times.
✗ Branch 9 not taken.
18327343 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1684 {
1685 18326449 sprite::move(s);
1686 18326449 }
1687 18327343 }
1688
1689 43683 void enemy::leave_item()
1690 {
1691 43683 int32_t drop_item = select_dropitem(item_set, x, y);
1692 43683 int32_t thedropset = item_set;
1693
1694 43683 std::vector<int32_t> &ev = FFCore.eventData;
1695 43683 ev.clear();
1696 43683 ev.push_back(getUID());
1697 43683 ev.push_back(drop_item*10000);
1698 43683 ev.push_back(thedropset*10000);
1699
1700 43683 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1701 43683 drop_item = vbound(ev[1] / 10000,-2,255);
1702 43683 thedropset = ev[2] / 10000;
1703 43683 ev.clear();
1704
1/2
✓ Branch 0 taken 43683 times.
✗ Branch 1 not taken.
43683 if(drop_item == -2)
1705 {
1706 drop_item = select_dropitem(thedropset,x,y);
1707 }
1708
1709
6/6
✓ Branch 0 taken 16429 times.
✓ Branch 1 taken 27254 times.
✓ Branch 2 taken 917 times.
✓ Branch 3 taken 15512 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 748 times.
43683 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1710 {
1711 item* itm;
1712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16260 times.
16260 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1713 {
1714 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1715 }
1716 else
1717 {
1718
8/14
✓ Branch 0 taken 1629 times.
✓ Branch 1 taken 14631 times.
✓ Branch 2 taken 1629 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1629 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1629 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1629 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1629 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1629 times.
✗ Branch 13 not taken.
16260 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1719
4/8
✓ Branch 0 taken 14631 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14631 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14631 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14631 times.
✗ Branch 7 not taken.
14631 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1720 }
1721 16260 itm->from_dropset = thedropset;
1722 16260 items.add(itm);
1723
1724 16260 ev.push_back(getUID());
1725 16260 ev.push_back(itm->getUID());
1726
1727 16260 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1728 16260 ev.clear();
1729 16260 }
1730 43683 }
1731
1732 // auomatically kill off enemy (for rooms with ringleaders)
1733 397 void enemy::kickbucket()
1734 {
1735
3/4
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 365 times.
✗ Branch 3 not taken.
397 if(!superman && !(flags2&guy_ignore_kill_all))
1736 365 hp=-1000; // don't call death_sfx()
1737 397 }
1738
1739 21250 bool enemy::isSubmerged() const
1740 {
1741 21250 return submerged;
1742 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1743 }
1744
1745 20952 void enemy::FireBreath(bool seekhero)
1746 {
1747
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1748 return;
1749
1750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1751 {
1752 dmisc1 = e1tEACHTILE;
1753 FireWeapon();
1754 return;
1755 }
1756
1757 20952 float fire_angle=0.0;
1758 20952 int32_t wx=0, wy=0, wdir=dir;
1759
1760
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1761 {
1762
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1763 {
1764 case down:
1765 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1766 3079 wx=x;
1767 3079 wy=y+8;
1768 3079 break;
1769
1770 case -1:
1771 case up:
1772 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1773 3297 wx=x;
1774 3297 wy=y-8;
1775 3297 break;
1776
1777 case left:
1778 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1779 5287 wx=x-8;
1780 5287 wy=y;
1781 5287 break;
1782
1783 case right:
1784 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1785 4208 wx=x+8;
1786 4208 wy=y;
1787 4208 break;
1788 }
1789
1790
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1791 {
1792
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1798
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1799
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1800 15735 }
1801 15871 }
1802 else
1803 {
1804 5081 wx = x;
1805 5081 wy = y;
1806 }
1807
1808
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1809 20952 sfx(wpnsfx(wpn),pan(int32_t(x)));
1810
1811 20952 int32_t i=Ewpns.Count()-1;
1812 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1813 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1814
1815
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1816 {
1817 7957 ew->angular=true;
1818 7957 ew->angle=fire_angle;
1819 7957 }
1820
1821
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1822 {
1823 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1825 20359 }
1826
1827
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1828 {
1829 766199 Ewpns.swap(j,j-1);
1830 766199 }
1831 20952 }
1832
1833 44653 void enemy::FireWeapon()
1834 {
1835 /*
1836 * Type:
1837 * 0x01: Boss fireball
1838 * 0x02: Seeks Hero
1839 * 0x04: Fast projectile
1840 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1841 */
1842
1843
2/2
✓ Branch 0 taken 44522 times.
✓ Branch 1 taken 131 times.
44653 if (wpn < 1) return;
1844
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44522 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1845 return;
1846
1847
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44522 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44522 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1848 dmisc1 = e1tEACHTILE;
1849
1850 44522 int32_t xoff = 0;
1851 44522 int32_t yoff = 0;
1852
1/2
✓ Branch 0 taken 44522 times.
✗ Branch 1 not taken.
44522 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
1853 {
1854 xoff += (hit_width/2)-8;
1855 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
1856 }
1857
1/2
✓ Branch 0 taken 44522 times.
✗ Branch 1 not taken.
44522 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
1858 {
1859 yoff += (hit_height/2)-8;
1860 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
1861 }
1862
1863
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41523 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44522 switch(dmisc1)
1864 {
1865 case e1t5SHOTS: //BS-Aquamentus
1866 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1867 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1868 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1869 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1870
1871 [[fallthrough]];
1872 case e1t3SHOTSFAST:
1873 case e1t3SHOTS: //Aquamentus
1874
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1875 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1876
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1877 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1878
1879 [[fallthrough]];
1880 default:
1881
12/20
✓ Branch 0 taken 42169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42169 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42169 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42169 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42169 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 42164 times.
✓ Branch 12 taken 42169 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 23931 times.
✓ Branch 16 taken 42169 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 42169 times.
✗ Branch 19 not taken.
42169 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1882 42169 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1883 42169 sfx(wpnsfx(wpn),pan(int32_t(x)));
1884 42169 break;
1885
1886 case e1tSLANT:
1887 {
1888 416 int32_t slant = 0;
1889
1890
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1891 246 slant = left;
1892
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1893 117 slant = right;
1894
1895
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1896 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1897 330 sfx(wpnsfx(wpn),pan(int32_t(x)));
1898 330 break;
1899 }
1900
1901 case e1t8SHOTS: //Fire Wizzrobe
1902
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1903 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1904 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1905
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1906 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1907 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1908
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1909 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1910 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1911
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1912 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1913 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1914
1915 [[fallthrough]];
1916 case e1t4SHOTS: //Stalfos 3
1917
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1918 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1919 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1920
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1921 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1922 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1923
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1924 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1925 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1926
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1927 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1928 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1929 1937 sfx(wpnsfx(wpn),pan(int32_t(x)));
1930 1937 break;
1931
1932 case e1tSUMMON: // Bat Wizzrobe
1933 {
1934 if(dmisc4==0) break; // Summon 0
1935
1936 int32_t bc=0;
1937
1938 for(int32_t gc=0; gc<guys.Count(); gc++)
1939 {
1940 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1941 {
1942 ++bc;
1943 }
1944 }
1945
1946 if(bc<=40) // Not too many enemies
1947 {
1948 int32_t kids = guys.Count();
1949 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1950
1951 for(int32_t i=0; i<bats; i++)
1952 {
1953 if(addchild(x,y,dmisc3,-10, this->script_UID))
1954 {
1955 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1956
1957 }
1958 }
1959
1960 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
1961 }
1962
1963 break;
1964 }
1965
1966 case e1tSUMMONLAYER: // Summoner
1967 {
1968 if(count_layer_enemies()==0)
1969 {
1970 break;
1971 }
1972
1973 int32_t kids = guys.Count();
1974
1975 if(kids<40)
1976 {
1977 int32_t newguys=(zc_oldrand()%3)+1;
1978 bool summoned=false;
1979
1980 for(int32_t i=0; i<newguys; i++)
1981 {
1982 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
1983 int32_t x2=0;
1984 int32_t y2=0;
1985
1986 for(int32_t k=0; k<20; ++k)
1987 {
1988 x2=16*((zc_oldrand()%12)+2);
1989 y2=16*((zc_oldrand()%7)+2);
1990
1991 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
1992 {
1993 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
1994 {
1995 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1996 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
1997 {
1998 ((enemy*)guys.spr(kids+i))->fakez = 64;
1999 ((enemy*)guys.spr(kids+i))->z = 0;
2000 }
2001 }
2002
2003 summoned=true;
2004 break;
2005 }
2006 }
2007 }
2008
2009 if(summoned)
2010 {
2011 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2012 }
2013 }
2014
2015 break;
2016 }
2017 }
2018 44567 }
2019
2020
2021 // Hit the shield(s)?
2022 // Apparently, this function is only used for hookshots...
2023 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2024 {
2025
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2026 834 return false;
2027
2028 1933 bool ret = false;
2029
2030 // TODO: There must be some bitwise operations that can simplify this...
2031
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2032
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2033
2034
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2035
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2036
2037 1933 return ret;
2038 2767 }
2039
2040
2041 //! Weapon Editor for 2.6
2042 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2043
2044
2045 //converts a wqeapon ID to its defence index.
2046 126847 int32_t weaponToDefence(int32_t wid)
2047 {
2048
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64405 times.
✓ Branch 2 taken 9432 times.
✓ Branch 3 taken 25029 times.
✓ Branch 4 taken 4207 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3146 times.
✓ Branch 9 taken 9836 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1217 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2036 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 26 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
126847 switch(wid)
2049 {
2050 case wNone: return -1;
2051 64405 case wSword: return edefSWORD;
2052 9432 case wBeam: return edefBEAM;
2053 25029 case wBrang: return edefBRANG;
2054 4207 case wBomb: return edefBOMB;
2055 37 case wSBomb: return edefSBOMB;
2056 48 case wLitBomb: return edefBOMB;
2057 case wLitSBomb: return edefSBOMB;
2058 3146 case wArrow: return edefARROW;
2059 9836 case wFire: return edefFIRE;
2060 case wWhistle:
2061 {
2062 return edefWhistle;
2063 }
2064 case wBait: return edefBAIT;
2065 269 case wWand: return edefWAND;
2066 1217 case wMagic: return edefMAGIC;
2067 case wCatching: return -1;
2068 case wWind: return edefWIND;
2069 512 case wRefMagic: return edefREFMAGIC;
2070 1459 case wRefFireball: return edefREFBALL;
2071 case wRefRock: return edefREFROCK;
2072 2036 case wHammer: return edefHAMMER;
2073 2767 case wHookshot: return edefHOOKSHOT;
2074 610 case wHSHandle: return edefHOOKSHOT;
2075 case wHSChain: return edefHOOKSHOT;
2076 240 case wSSparkle: return edefSPARKLE;
2077 469 case wFSparkle: return edefSPARKLE;
2078 case wSmack: return -1; // is this the candle object?
2079 case wPhantom: return -1; //engine created visual effects.
2080 case wCByrna: return edefBYRNA;
2081 19 case wRefBeam: return edefREFBEAM;
2082 case wStomp: return edefSTOMP;
2083 26 case wScript1: return edefSCRIPT01;
2084 case wScript2: return edefSCRIPT02;
2085 12 case wScript3: return edefSCRIPT03;
2086 77 case wScript4: return edefSCRIPT04;
2087 case wScript5: return edefSCRIPT05;
2088 case wScript6: return edefSCRIPT06;
2089 case wScript7: return edefSCRIPT07;
2090 case wScript8: return edefSCRIPT08;
2091 case wScript9: return edefSCRIPT09;
2092 993 case wScript10: return edefSCRIPT10;
2093 case wIce: return edefICE;
2094 case wSound: return edefSONIC;
2095 1 case wThrown: return edefTHROWN;
2096 case wRefArrow: return edefREFARROW;
2097 case wRefFire: return edefREFFIRE;
2098 case wRefFire2: return edefREFFIRE2;
2099 //case wPot: return edefPOT;
2100 // case wLitZap: return edefELECTRIC;
2101 // case wZ3Sword: return edefZ3SWORD;
2102 // case wLASWord: return edefLASWORD;
2103 // case wSpinAttk: return edefSPINATTK;
2104 // case wShield: return edefSHIELD;
2105 // case wTrowel: return edefTROWEL;
2106
2107 default: return -1;
2108 }
2109 126847 }
2110
2111 126847 int32_t getDefType(weapon *w)
2112 {
2113 126847 int32_t id = getWeaponID(w);
2114 126847 int32_t edef = weaponToDefence(id);
2115
2/2
✓ Branch 0 taken 123470 times.
✓ Branch 1 taken 3377 times.
126847 if(edef == edefHOOKSHOT)
2116 {
2117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2118 return edefSwitchHook;
2119 3377 }
2120 126847 return edef;
2121 126847 }
2122
2123 225898 int32_t getWeaponID(weapon *w)
2124 {
2125 225898 int32_t usewpn = w->useweapon;
2126
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 225668 times.
225898 return (usewpn > 0) ? usewpn : w->id;
2127 }
2128
2129 126847 int32_t enemy::resolveEnemyDefence(weapon *w)
2130 {
2131 //sword edef is 9, but we're reading it at 0
2132 //,
2133 126847 int32_t weapondef = 0;
2134 126847 int32_t wdeftype = getDefType(w);
2135 126847 int32_t usedef = w->usedefence;
2136
2137
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 126847 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
126847 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2138 {
2139 weapondef = usedef*-1;
2140 }
2141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126847 times.
126847 else if(unsigned(wdeftype) < edefLAST255)
2142 {
2143 126847 weapondef = wdeftype;
2144 126847 }
2145 126847 return weapondef;
2146 }
2147
2148 137389 byte get_def_ignrflag(int32_t edef)
2149 {
2150
3/3
✓ Branch 0 taken 114463 times.
✓ Branch 1 taken 3664 times.
✓ Branch 2 taken 19262 times.
137389 switch(edef)
2151 {
2152 case edIGNORE:
2153 case edIGNOREL1:
2154 case edSTUNORIGNORE:
2155 19262 return WPNUNB_IGNR;
2156 case edSTUNORCHINK:
2157 case edCHINK:
2158 case edCHINKL1:
2159 case edCHINKL2:
2160 case edCHINKL4:
2161 case edCHINKL6:
2162 case edCHINKL8:
2163 case edCHINKL10:
2164 case edLEVELCHINK2:
2165 case edLEVELCHINK3:
2166 case edLEVELCHINK4:
2167 case edLEVELCHINK5:
2168 3664 return WPNUNB_BLOCK;
2169 }
2170 114463 return 0;
2171 137389 }
2172
2173 137389 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2174 {
2175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137389 times.
137389 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2176 switch(edef)
2177 {
2178 case edIGNORE:
2179 case edIGNOREL1:
2180 case edCHINK:
2181 case edCHINKL1:
2182 case edCHINKL2:
2183 case edCHINKL4:
2184 case edCHINKL6:
2185 case edCHINKL8:
2186 case edCHINKL10:
2187 case edLEVELCHINK2:
2188 case edLEVELCHINK3:
2189 case edLEVELCHINK4:
2190 case edLEVELCHINK5:
2191 return edNORMAL;
2192 case edSTUNORIGNORE:
2193 case edSTUNORCHINK:
2194 return edSTUNONLY;
2195 }
2196 return edef;
2197 137389 }
2198
2199 // Do we do damage?
2200 // 0: takehit returns 0
2201 // 1: takehit returns 1
2202 // -1: do damage
2203 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2204 125854 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2205 {
2206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125854 times.
125854 if(switch_hooked) return 0;
2207 125854 int32_t tempx = x;
2208 125854 int32_t tempy = y;
2209 125854 int32_t the_defence = 0;
2210
1/2
✓ Branch 0 taken 125854 times.
✗ Branch 1 not taken.
125854 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2211 {
2212 the_defence = edef*-1; //A specific defence type.
2213 }
2214 125854 else the_defence = defense[edef];
2215
2216 125854 the_defence = conv_edef_unblockable(the_defence, unblockable);
2217
2218
3/4
✓ Branch 0 taken 6557 times.
✓ Branch 1 taken 119297 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6557 times.
125854 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2219 {
2220
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6550 times.
✓ Branch 2 taken 7 times.
6557 switch(the_defence)
2221 {
2222 case edIGNORE:
2223 7 return 0;
2224 case edIGNOREL1:
2225 case edSTUNORIGNORE:
2226 if(*power <= 0)
2227 return 0;
2228 }
2229 6550 sfx(WAV_CHINK,pan(int32_t(x)));
2230 6550 return 1;
2231 }
2232
2233 119297 int32_t new_id = id;
2234 119297 int32_t effect_type = dmisc15;
2235 119297 int32_t delay_timer = 90;
2236 119297 enemy *gleeok = NULL;
2237 119297 enemy *ptra = NULL;
2238 119297 int32_t c = 0;
2239
2240
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1862 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 930 times.
✓ Branch 13 taken 17324 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2179 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93072 times.
119297 switch(the_defence)
2241 {
2242 case edREPLACE:
2243 {
2244 sclk = 0;
2245 if ( dmisc16 > 0 ) new_id = dmisc16;
2246 else new_id = id+1;
2247 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2248 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2249 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2250
2251 //Z_scripterrlog("new id is %d\n", new_id);
2252 switch(guysbuf[new_id&0xFFF].family)
2253 {
2254 //Fixme: possible enemy memory leak. (minor)
2255 case eeWALK:
2256 {
2257 enemy *e = new eStalfos(x,y,new_id,clk);
2258 guys.add(e);
2259 }
2260 break;
2261
2262 case eeLEV:
2263 {
2264 enemy *e = new eLeever(x,y,new_id,clk);
2265 guys.add(e);
2266 }
2267 break;
2268
2269 case eeTEK:
2270 {
2271 enemy *e = new eTektite(x,y,new_id,clk);
2272 guys.add(e);
2273 }
2274 break;
2275
2276 case eePEAHAT:
2277 {
2278 enemy *e = new ePeahat(x,y,new_id,clk);
2279 guys.add(e);
2280 }
2281 break;
2282
2283 case eeZORA:
2284 {
2285 enemy *e = new eZora(x,y,new_id,clk);
2286 guys.add(e);
2287 }
2288 break;
2289
2290 case eeGHINI:
2291 {
2292 enemy *e = new eGhini(x,y,new_id,clk);
2293 guys.add(e);
2294 }
2295 break;
2296
2297 case eeKEESE:
2298 {
2299 enemy *e = new eKeese(x,y,new_id,clk);
2300 guys.add(e);
2301 }
2302 break;
2303
2304 case eeWIZZ:
2305 {
2306 enemy *e = new eWizzrobe(x,y,new_id,clk);
2307 guys.add(e);
2308 }
2309 break;
2310
2311 case eePROJECTILE:
2312 {
2313 enemy *e = new eProjectile(x,y,new_id,clk);
2314 guys.add(e);
2315 }
2316 break;
2317
2318 case eeWALLM:
2319 {
2320 enemy *e = new eWallM(x,y,new_id,clk);
2321 guys.add(e);
2322 }
2323 break;
2324
2325 case eeAQUA:
2326 {
2327 enemy *e = new eAquamentus(x,y,new_id,clk);
2328 guys.add(e);
2329 e->x = x;
2330 e->y = y;
2331 }
2332 break;
2333
2334 case eeMOLD:
2335 {
2336 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2337 guys.add(e);
2338 e->x = x;
2339 e->y = y;
2340 }
2341 break;
2342
2343 case eeMANHAN:
2344 {
2345 enemy *e = new eManhandla(x,y,new_id,clk);
2346 guys.add(e);
2347 e->x = x;
2348 e->y = y;
2349 }
2350 break;
2351
2352 case eeGLEEOK:
2353 {
2354 *power = 0;
2355 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2356 guys.add(gleeok);
2357 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2358 new_id &= 0xFFF;
2359 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2360 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2361 for(int32_t i=0; i<head_cnt; i++)
2362 {
2363 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2364 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2365 {
2366 al_trace("Gleeok head %d could not be created!\n",i+1);
2367
2368 for(int32_t j=0; j<i+1; j++)
2369 {
2370 guys.del(guys.Count()-1);
2371 }
2372
2373 break;
2374 }
2375 else
2376 {
2377 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2378 }
2379
2380 c-=guysbuf[new_id].attributes[3];
2381 //gleeok->x = x;
2382 //gleeok->y = y;
2383 //gleeok = e;
2384 }
2385 return 1;
2386 }
2387
2388 case eeGHOMA:
2389 {
2390 enemy *e = new eGohma(x,y,new_id,clk);
2391 guys.add(e);
2392 e->x = x;
2393 e->y = y;
2394 }
2395 break;
2396
2397 case eeLANM:
2398 {
2399 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2400 guys.add(e);
2401 e->x = x;
2402 e->y = y;
2403 }
2404 break;
2405
2406 case eeGANON:
2407 {
2408 enemy *e = new eGanon(x,y,new_id,clk);
2409 guys.add(e);
2410 e->x = x;
2411 e->y = y;
2412 }
2413 break;
2414
2415 case eeFAIRY:
2416 {
2417 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2418 guys.add(e);
2419 e->x = x;
2420 e->y = y;
2421 }
2422 break;
2423
2424 case eeFIRE:
2425 {
2426 enemy *e = new eFire(x,y,new_id,clk);
2427 guys.add(e);
2428 e->x = x;
2429 e->y = y;
2430 }
2431 break;
2432
2433 case eeOTHER:
2434 {
2435 enemy *e = new eOther(x,y,new_id,clk);
2436 guys.add(e);
2437 e->x = x;
2438 e->y = y;
2439 }
2440 break;
2441
2442 case eeSPINTILE:
2443 {
2444 enemy *e = new eSpinTile(x,y,new_id,clk);
2445 guys.add(e);
2446 e->x = x;
2447 e->y = y;
2448 }
2449 break;
2450
2451 // and these enemies use the misc10/misc2 value
2452 case eeROCK:
2453 {
2454 switch(guysbuf[new_id&0xFFF].attributes[9])
2455 {
2456 case 1:
2457 {
2458 enemy *e = new eBoulder(x,y,new_id,clk);
2459 guys.add(e);
2460 e->x = x;
2461 e->y = y;
2462 }
2463 break;
2464
2465 case 0:
2466 default:
2467 {
2468 enemy *e = new eRock(x,y,new_id,clk);
2469 guys.add(e);
2470 e->x = x;
2471 e->y = y;
2472 }
2473 break;
2474 }
2475
2476 break;
2477 }
2478
2479 case eeTRAP:
2480 {
2481 switch(guysbuf[new_id&0xFFF].attributes[1])
2482 {
2483 case 1:
2484 {
2485 enemy *e = new eTrap2(x,y,new_id,clk);
2486 guys.add(e);
2487 e->x = x;
2488 e->y = y;
2489 }
2490 break;
2491
2492 case 0:
2493 default:
2494 {
2495 enemy *e = new eTrap(x,y,new_id,clk);
2496 guys.add(e);
2497 e->x = x;
2498 e->y = y;
2499 }
2500 break;
2501 }
2502
2503 break;
2504 }
2505
2506 case eeDONGO:
2507 {
2508 switch(guysbuf[new_id&0xFFF].attributes[9])
2509 {
2510 case 1:
2511 {
2512 enemy *e = new eDodongo2(x,y,new_id,clk);
2513 guys.add(e);
2514 e->x = x;
2515 e->y = y;
2516 }
2517 break;
2518
2519 case 0:
2520 default:
2521 {
2522 enemy *e = new eDodongo(x,y,new_id,clk);
2523 guys.add(e);
2524 e->x = x;
2525 e->y = y;
2526 }
2527 break;
2528 }
2529
2530 break;
2531 }
2532
2533 case eeDIG:
2534 {
2535 switch(guysbuf[new_id&0xFFF].attributes[9])
2536 {
2537 case 1:
2538 {
2539 enemy *e = new eLilDig(x,y,new_id,clk);
2540 guys.add(e);
2541 e->x = x;
2542 e->y = y;
2543 }
2544 break;
2545
2546 case 0:
2547 default:
2548 {
2549 enemy *e = new eBigDig(x,y,new_id,clk);
2550 guys.add(e);
2551 e->x = x;
2552 e->y = y;
2553 }
2554 break;
2555 }
2556
2557 break;
2558 }
2559
2560 case eePATRA:
2561 {
2562 switch(guysbuf[new_id&0xFFF].attributes[9])
2563 {
2564 case 1:
2565 {
2566 if (get_qr(qr_HARDCODED_BS_PATRA))
2567 {
2568 enemy *e = new ePatraBS(x,y,new_id,clk);
2569 guys.add(e);
2570 e->x = x;
2571 e->y = y;
2572 break;
2573 }
2574 }
2575 [[fallthrough]];
2576 case 0:
2577 default:
2578 {
2579 enemy *e = new ePatra(x,y,new_id,clk);
2580 guys.add(e);
2581 e->x = x;
2582 e->y = y;
2583 }
2584 break;
2585 }
2586
2587 break;
2588 }
2589
2590 case eeGUY:
2591 {
2592 switch(guysbuf[new_id&0xFFF].attributes[9])
2593 {
2594 case 1:
2595 {
2596 enemy *e = new eTrigger(x,y,new_id,clk);
2597 guys.add(e);
2598 }
2599 break;
2600
2601 case 0:
2602 default:
2603 {
2604 enemy *e = new eNPC(x,y,new_id,clk);
2605 guys.add(e);
2606 }
2607 break;
2608 }
2609
2610 break;
2611 }
2612
2613 case eeSCRIPT01:
2614 case eeSCRIPT02:
2615 case eeSCRIPT03:
2616 case eeSCRIPT04:
2617 case eeSCRIPT05:
2618 case eeSCRIPT06:
2619 case eeSCRIPT07:
2620 case eeSCRIPT08:
2621 case eeSCRIPT09:
2622 case eeSCRIPT10:
2623 case eeSCRIPT11:
2624 case eeSCRIPT12:
2625 case eeSCRIPT13:
2626 case eeSCRIPT14:
2627 case eeSCRIPT15:
2628 case eeSCRIPT16:
2629 case eeSCRIPT17:
2630 case eeSCRIPT18:
2631 case eeSCRIPT19:
2632 case eeSCRIPT20:
2633 {
2634 enemy *e = new eScript(x,y,new_id,clk);
2635 guys.add(e);
2636 e->x = x;
2637 e->y = y;
2638 break;
2639 }
2640
2641
2642 case eeFFRIENDLY01:
2643 case eeFFRIENDLY02:
2644 case eeFFRIENDLY03:
2645 case eeFFRIENDLY04:
2646 case eeFFRIENDLY05:
2647 case eeFFRIENDLY06:
2648 case eeFFRIENDLY07:
2649 case eeFFRIENDLY08:
2650 case eeFFRIENDLY09:
2651 case eeFFRIENDLY10:
2652 {
2653 enemy *e = new eFriendly(x,y,new_id,clk);
2654 guys.add(e);
2655 e->x = x;
2656 e->y = y;
2657 break;
2658 }
2659
2660
2661 default: break;
2662 }
2663
2664 // add segments of segmented enemies
2665 int32_t c=0;
2666
2667 switch(guysbuf[new_id&0xFFF].family)
2668 {
2669 case eeMOLD:
2670 {
2671 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2672 new_id &= 0xFFF;
2673
2674 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2675 {
2676 //christ this is messy -DD
2677 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2678
2679 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2680 {
2681 al_trace("Moldorm segment %d could not be created!\n",i+1);
2682
2683 for(int32_t j=0; j<i+1; j++)
2684 guys.del(guys.Count()-1);
2685
2686 return 0;
2687 }
2688
2689 if(i>0)
2690 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2691
2692
2693 }
2694
2695 break;
2696 }
2697
2698 case eeLANM:
2699 {
2700 new_id &= 0xFFF;
2701 int32_t shft = guysbuf[new_id].attributes[1];
2702 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2703 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2704
2705 if(!guys.add(e))
2706 {
2707 al_trace("Lanmola segment 1 could not be created!\n");
2708 guys.del(guys.Count()-1);
2709 return 0;
2710 }
2711 e->x = x;
2712 e->y = y;
2713
2714
2715
2716 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2717 {
2718 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2719 if(!guys.add(e2))
2720 {
2721 al_trace("Lanmola segment %d could not be created!\n",i+1);
2722
2723 for(int32_t j=0; j<i+1; j++)
2724 guys.del(guys.Count()-1);
2725
2726 return 0;
2727 }
2728 e2->x = x;
2729 e2->y = y;
2730
2731 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2732
2733 }
2734 }
2735 break;
2736
2737 case eeMANHAN:
2738 new_id &= 0xFFF;
2739
2740 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2741 {
2742 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2743 {
2744 al_trace("Manhandla head %d could not be created!\n",i+1);
2745
2746 for(int32_t j=0; j<i+1; j++)
2747 {
2748 guys.del(guys.Count()-1);
2749 }
2750
2751 return 0;
2752 }
2753
2754
2755 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2756 }
2757
2758 break;
2759
2760 case eeGLEEOK:
2761 {
2762 /*
2763 new_id &= 0xFFF;
2764 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2765 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2766 for(int32_t i=0; i<head_cnt; i++)
2767 {
2768 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2769 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2770 {
2771 al_trace("Gleeok head %d could not be created!\n",i+1);
2772
2773 for(int32_t j=0; j<i+1; j++)
2774 {
2775 guys.del(guys.Count()-1);
2776 }
2777
2778 break;
2779 }
2780
2781 c-=guysbuf[new_id].misc4;
2782 */
2783
2784 // }
2785 }
2786 break;
2787
2788
2789 case eePATRA:
2790 {
2791 new_id &= 0xFFF;
2792 int32_t outeyes = 0;
2793 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2794
2795 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2796 {
2797 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2798 {
2799 al_trace("Patra outer eye %d could not be created!\n",i+1);
2800
2801 for(int32_t j=0; j<i+1; j++)
2802 guys.del(guys.Count()-1);
2803
2804 return 0;
2805 }
2806 else
2807 outeyes++;
2808
2809
2810 }
2811
2812 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2813 {
2814 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2815 {
2816 al_trace("Patra inner eye %d could not be created!\n",i+1);
2817
2818 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2819 guys.del(guys.Count()-1);
2820
2821 return 0;
2822 }
2823
2824
2825 }
2826 delete ptra;
2827 break;
2828 }
2829 }
2830
2831
2832
2833 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2834 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2835 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2836 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2837 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2838 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2839 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2840 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2841 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2842 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2843 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2844 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
2845 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2846
2847
2848 item_set = 0; //Do not make a drop.
2849
2850 switch(effect_type)
2851 {
2852 case -7:
2853 {
2854 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2855 Lwpns.add(w);
2856 break;
2857 }
2858 case -6:
2859 {
2860 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2861 Lwpns.add(w);
2862 break;
2863 }
2864 case -5:
2865 {
2866 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2867 Lwpns.add(w);
2868 break;
2869 }
2870 case -4:
2871 {
2872 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2873 Lwpns.add(w);
2874 break;
2875 }
2876 case -3: explode(1); break;
2877 case -2: explode(2); break;
2878 case -1: explode(0); break;
2879 case 0: break;
2880
2881 default:
2882 {
2883 //Dummy weapon function
2884 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2885 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2886 Lwpns.add(w);
2887 break;
2888 }
2889 }
2890
2891
2892 yofs = -32768;
2893 switch(guysbuf[new_id&0xFFF].family)
2894 {
2895 case eeGLEEOK:
2896 {
2897 Z_scripterrlog("Replacing a gleeok.\n");
2898 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2899 hp = -999;
2900 tempenemy->hp = -999;
2901 break;
2902
2903 }
2904 default:
2905 hp = -1000; break;
2906 }
2907 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
2908 return 1;
2909
2910 }
2911 case edSPLIT:
2912 {
2913 for ( int32_t q = 0; q < dmisc4; q++ )
2914 {
2915 addenemy(
2916 //ex,ey,
2917 x,y,
2918 dmisc3+0x1000,-15);
2919
2920 }
2921 item_set = 0; //Do not make a drop.
2922 hp = -1000;
2923 return -1;
2924
2925 }
2926 case edSUMMON:
2927 {
2928 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
2929 for ( int32_t q = 0; q < summon_count; q++ )
2930 {
2931 int32_t x2=16*((zc_oldrand()%12)+2);
2932 int32_t y2=16*((zc_oldrand()%7)+2);
2933 addenemy(
2934 x2,y2,
2935 dmisc3+0x1000,-15);
2936
2937 }
2938 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2939 return -1;
2940
2941 }
2942
2943 case edEXPLODESMALL:
2944 {
2945 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2946 Ewpns.add(ew);
2947 item_set = 0; //Should we make a drop?
2948 hp = -1000;
2949 return -1;
2950 }
2951
2952
2953 case edEXPLODEHARMLESS:
2954 {
2955 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2956 Ewpns.add(ew);
2957 ew->hyofs = -32768;
2958 item_set = 0; //Should we make a drop?
2959 hp = -1000;
2960 return -1;
2961 }
2962
2963
2964 case edEXPLODELARGE:
2965 {
2966 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2967 Ewpns.add(ew);
2968
2969 hp = -1000;
2970 return -1;
2971 }
2972
2973
2974 case edTRIGGERSECRETS:
2975 {
2976 hidden_entrance(0, true, false, -4);
2977 return -1;
2978 }
2979
2980 case edSTUNORCHINK:
2981
3/4
✓ Branch 0 taken 1123 times.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 1123 times.
✗ Branch 3 not taken.
3709 if (stunclk && get_qr(qr_NO_STUNLOCK))
2982 {
2983 sfx(WAV_CHINK,pan(int32_t(x)));
2984 return 1;
2985 }
2986
2/2
✓ Branch 0 taken 649 times.
✓ Branch 1 taken 1530 times.
2179 else if(*power <= 0)
2987 {
2988 649 sfx(WAV_CHINK,pan(int32_t(x)));
2989 649 return 1;
2990 }
2991 [[fallthrough]];
2992
2993 case edSTUNORIGNORE:
2994
3/4
✓ Branch 0 taken 1956 times.
✓ Branch 1 taken 1505 times.
✓ Branch 2 taken 1956 times.
✗ Branch 3 not taken.
5967 if (stunclk && get_qr(qr_NO_STUNLOCK))
2995 {
2996 sfx(WAV_CHINK,pan(int32_t(x)));
2997 return 1;
2998 }
2999
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2506 times.
3461 else if(*power <= 0)
3000 955 return 0;
3001 [[fallthrough]];
3002
3003 case edSTUNONLY:
3004
7/10
✓ Branch 0 taken 4368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4368 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3821 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4047 times.
✓ Branch 9 taken 321 times.
4368 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3005 {
3006 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3007 321 return 1;
3008 }
3009
3/4
✓ Branch 0 taken 3122 times.
✓ Branch 1 taken 925 times.
✓ Branch 2 taken 3122 times.
✗ Branch 3 not taken.
4047 if (stunclk && get_qr(qr_NO_STUNLOCK))
3010 {
3011 sfx(WAV_CHINK,pan(int32_t(x)));
3012 return 1;
3013 }
3014 else
3015 {
3016 4047 stunclk=160;
3017 4047 sfx(WAV_EHIT,pan(int32_t(x)));
3018
3019 4047 return 1;
3020 }
3021
3022 case edCHINKL1:
3023 if(*power >= 1*game->get_hero_dmgmult()) break;
3024 [[fallthrough]];
3025 case edCHINKL2:
3026
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3027 [[fallthrough]];
3028 case edCHINKL4:
3029
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3030 [[fallthrough]];
3031 case edCHINKL6:
3032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3033 [[fallthrough]];
3034 case edCHINKL8:
3035
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3036 [[fallthrough]];
3037 case edCHINKL10:
3038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3039 [[fallthrough]];
3040 case edCHINK:
3041 1041 sfx(WAV_CHINK,pan(int32_t(x)));
3042 1041 return 1;
3043
3044 case edIGNOREL1:
3045 if(*power > 0) break;
3046 [[fallthrough]];
3047
3048 case edIGNORE:
3049 17324 return 0;
3050
3051 case ed1HKO:
3052 492 *power = hp;
3053 492 return -2;
3054
3055 case ed2x:
3056 {
3057
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3058 //int32_t pow = *power;
3059 //*power = vbound((pow*2),0,214747);
3060 71 return -1;
3061 }
3062 case ed3x:
3063 {
3064 *power = zc_max(1,*power*3);
3065 //int32_t pow = *power;
3066 //*power = vbound((pow*3),0,214747);
3067 return -1;
3068 }
3069
3070 case ed4x:
3071 {
3072 *power = zc_max(1,*power*4);
3073 //int32_t pow = *power;
3074 //*power = vbound((pow*4),0,214747);
3075 return -1;
3076 }
3077
3078
3079 case edHEAL:
3080 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3081 //int32_t pow = *power;
3082 //*power = vbound((pow*-1),0,214747);
3083 //break;
3084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3085 158 return -1;
3086 }
3087 /*
3088 case edLEVELDAMAGE:
3089 {
3090 int32_t pow = *power;
3091 int32_t lvl = *level;
3092 *power = vbound((pow*lvl),0,214747);
3093 break;
3094 }
3095 case edLEVELREDUCTION:
3096 {
3097 int32_t pow = *power;
3098 int32_t lvl = *level;
3099 *power = vbound((pow/lvl),0,214747);
3100 break;
3101 }
3102 */
3103
3104 case edQUARTDAMAGE:
3105
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3106
3107 [[fallthrough]];
3108 case edHALFDAMAGE:
3109
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3110 988 break;
3111
3112 case edSWITCH:
3113 {
3114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(family)
3116 {
3117 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3118 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3119 return 0;
3120 }
3121 4 hooked_combopos = -1;
3122 4 hooked_layerbits = 0;
3123 4 switching_object = this;
3124 4 switch_hooked = true;
3125 4 Hero.doSwitchHook(game->get_switchhookstyle());
3126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3127 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3128 4 return 1;
3129 }
3130
3131 case 0:
3132 {
3133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93072 times.
93072 if(edef == edefSwitchHook)
3134 return -1;
3135
6/6
✓ Branch 0 taken 19536 times.
✓ Branch 1 taken 73536 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 19478 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 26 times.
93072 if (stunclk && get_qr(qr_NO_STUNLOCK) && *power == 0)
3136 {
3137 26 sfx(WAV_CHINK,pan(int32_t(x)));
3138 26 return 1;
3139 }
3140
3141 }
3142 93046 }
3143
3144 94209 return -1;
3145 125854 }
3146
3147 125854 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3148 {
3149
1/2
✓ Branch 0 taken 125854 times.
✗ Branch 1 not taken.
125854 int wuid = w?w->getUID():0;
3150
1/2
✓ Branch 0 taken 125854 times.
✗ Branch 1 not taken.
125854 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3151
3152
1/2
✓ Branch 0 taken 125854 times.
✗ Branch 1 not taken.
125854 if(fakeweap)
3153 Lwpns.add(w);
3154 125854 std::vector<int32_t> &ev = FFCore.eventData;
3155 125854 ev.clear();
3156 125854 ev.push_back(*power*10000);
3157 125854 ev.push_back(edef*10000);
3158 125854 ev.push_back(unblockable*10000);
3159 125854 ev.push_back(wpnId*10000);
3160 125854 ev.push_back(0);
3161 125854 ev.push_back(getUID());
3162 125854 ev.push_back(wuid);
3163
3164 125854 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3165 125854 *power = ev[0]/10000;
3166 125854 edef = ev[1]/10000;
3167 125854 unblockable = byte(ev[2]/10000);
3168 125854 wpnId = ev[3] / 10000;
3169 125854 bool nullify = ev[4]!=0;
3170 125854 ev.clear();
3171 125854 int ret = 0;
3172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125854 times.
125854 if(!nullify)
3173 {
3174 125854 ret = defendNew(wpnId, power, edef, unblockable);
3175
2/2
✓ Branch 0 taken 32778 times.
✓ Branch 1 taken 93076 times.
125854 if(ret == -1)
3176 {
3177 93076 ev.push_back(*power*10000);
3178 93076 ev.push_back(edef*10000);
3179 93076 ev.push_back(unblockable*10000);
3180 93076 ev.push_back(wpnId*10000);
3181 93076 ev.push_back(0);
3182 93076 ev.push_back(getUID());
3183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93076 times.
93076 ev.push_back(w?w->getUID():0);
3184
3185 93076 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3186 93076 *power = ev[0]/10000;
3187 93076 nullify = ev[4]!=0;
3188 93076 ev.clear();
3189 93076 }
3190 125854 }
3191
1/2
✓ Branch 0 taken 125854 times.
✗ Branch 1 not taken.
125854 if(fakeweap)
3192 Lwpns.remove(w);
3193
3194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125854 times.
125854 return nullify ? 0 : ret;
3195 }
3196
3197 99051 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3198 {
3199
2/2
✓ Branch 0 taken 98474 times.
✓ Branch 1 taken 577 times.
99051 if(!realweap) realweap = w;
3200 99051 int32_t wid = getWeaponID(w);
3201
3202 99051 int32_t edef = resolveEnemyDefence(w);
3203
2/2
✓ Branch 0 taken 5832 times.
✓ Branch 1 taken 93219 times.
99051 if(QHeader.zelda_version > 0x250)
3204 5832 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3205
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92226 times.
✗ Branch 2 not taken.
93219 switch(wid)
3206 {
3207 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3208 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3209 993 return defend(wpnId, power, edefSCRIPT);
3210
3211 case wWhistle:
3212 return -1;
3213
3214 default:
3215 92226 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3216 }
3217 99051 }
3218
3219
3220 // Check defenses without actually acting on them.
3221 27424 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3222 {
3223
4/10
✓ Branch 0 taken 15431 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27424 switch(defense[edef])
3224 {
3225 case edSTUNONLY:
3226 474 return false;
3227 case edSTUNORCHINK:
3228 case edCHINK:
3229 15431 return unblockable&WPNUNB_BLOCK;
3230 case edSTUNORIGNORE:
3231 case edIGNORE:
3232 11050 return unblockable&WPNUNB_IGNR;
3233
3234 case edIGNOREL1:
3235 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3236 case edCHINKL1:
3237 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3238
3239 case edCHINKL2:
3240 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3241
3242 case edCHINKL4:
3243 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3244
3245 case edCHINKL6:
3246 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3247
3248 case edCHINKL8:
3249 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3250 }
3251
3252 469 return true;
3253 27424 }
3254
3255 // Do we do damage?
3256 // 0: takehit returns 0
3257 // 1: takehit returns 1
3258 // -1: do damage
3259 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3260 {
3261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3262 {
3263 switch(defense[edef])
3264 {
3265 case edIGNORE:
3266 return 0;
3267 case edIGNOREL1:
3268 case edSTUNORIGNORE:
3269 if(*power <= 0)
3270 return 0;
3271 }
3272
3273 sfx(WAV_CHINK,pan(int32_t(x)));
3274 return 1;
3275 }
3276
3277
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3278 {
3279 case edSTUNORCHINK:
3280 if(*power <= 0)
3281 {
3282 sfx(WAV_CHINK,pan(int32_t(x)));
3283 return 1;
3284 }
3285
3286 [[fallthrough]];
3287 case edSTUNORIGNORE:
3288 if(*power <= 0)
3289 return 0;
3290
3291 [[fallthrough]];
3292 case edSTUNONLY:
3293 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3294 return 1;
3295
3296 stunclk=160;
3297 sfx(WAV_EHIT,pan(int32_t(x)));
3298 return 1;
3299
3300 case edFREEZE:
3301 frozenclock=-1;
3302 //sfx(WAV_FREEZE,pan(int32_t(x)));
3303 return 1;
3304
3305 case edCHINKL1:
3306 if(*power >= 1*game->get_hero_dmgmult()) break;
3307 [[fallthrough]];
3308 case edCHINKL2:
3309 if(*power >= 2*game->get_hero_dmgmult()) break;
3310 [[fallthrough]];
3311 case edCHINKL4:
3312 if(*power >= 4*game->get_hero_dmgmult()) break;
3313 [[fallthrough]];
3314 case edCHINKL6:
3315 if(*power >= 6*game->get_hero_dmgmult()) break;
3316 [[fallthrough]];
3317 case edCHINKL8:
3318 if(*power >= 8*game->get_hero_dmgmult()) break;
3319 [[fallthrough]];
3320 case edCHINKL10:
3321 if(*power >= 10*game->get_hero_dmgmult()) break;
3322 [[fallthrough]];
3323 case edCHINK:
3324 sfx(WAV_CHINK,pan(int32_t(x)));
3325 return 1;
3326 case edTRIGGERSECRETS:
3327 hidden_entrance(0, true, false, -4);
3328 break;
3329
3330 case edIGNOREL1:
3331 if(*power > 0) break;
3332 [[fallthrough]];
3333 case edIGNORE:
3334 800 return 0;
3335
3336 case ed1HKO:
3337 *power = hp;
3338 return -2;
3339
3340 case ed2x:
3341 {
3342 *power = zc_max(1,*power*2);
3343 //int32_t pow = *power;
3344 //*power = vbound((pow*2),0,214747);
3345 return -1;
3346 }
3347 case ed3x:
3348 {
3349 *power = zc_max(1,*power*3);
3350 //int32_t pow = *power;
3351 //*power = vbound((pow*3),0,214747);
3352 return -1;
3353 }
3354
3355 case ed4x:
3356 {
3357 *power = zc_max(1,*power*4);
3358 //int32_t pow = *power;
3359 //*power = vbound((pow*4),0,214747);
3360 return -1;
3361 }
3362
3363
3364 case edHEAL:
3365 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3366 //int32_t pow = *power;
3367 //*power = vbound((pow*-1),0,214747);
3368 //break;
3369 *power = zc_min(0,*power*-1);
3370 return -1;
3371 }
3372 /*
3373 case edLEVELDAMAGE:
3374 {
3375 int32_t pow = *power;
3376 int32_t lvl = *level;
3377 *power = vbound((pow*lvl),0,214747);
3378 break;
3379 }
3380 case edLEVELREDUCTION:
3381 {
3382 int32_t pow = *power;
3383 int32_t lvl = *level;
3384 *power = vbound((pow/lvl),0,214747);
3385 break;
3386 }
3387 */
3388
3389
3390 case edQUARTDAMAGE:
3391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3392
3393 [[fallthrough]];
3394 case edHALFDAMAGE:
3395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3396 7 break;
3397 }
3398
3399 193 return -1;
3400 993 }
3401
3402 // Defend against a particular item class.
3403 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3404 {
3405 int32_t def=-1;
3406
3407 switch(wpnId)
3408 {
3409 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3410 case wBrang:
3411 def = defend(wpnId, power, edefBRANG);
3412 break;
3413
3414 case wHookshot:
3415 def = defend(wpnId, power, edefHOOKSHOT);
3416 break;
3417
3418 // Anyway...
3419 case wBomb:
3420 def = defend(wpnId, power, edefBOMB);
3421 break;
3422
3423 case wSBomb:
3424 def = defend(wpnId, power, edefSBOMB);
3425 break;
3426
3427 case wArrow:
3428 def = defend(wpnId, power, edefARROW);
3429 break;
3430
3431 case wFire:
3432 def = defend(wpnId, power, edefFIRE);
3433 break;
3434
3435 case wWand:
3436 def = defend(wpnId, power, edefWAND);
3437 break;
3438
3439 case wMagic:
3440 def = defend(wpnId, power, edefMAGIC);
3441 break;
3442
3443 case wHammer:
3444 def = defend(wpnId, power, edefHAMMER);
3445 break;
3446
3447 case wSword:
3448 def = defend(wpnId, power, edefSWORD);
3449 break;
3450
3451 case wBeam:
3452 def = defend(wpnId, power, edefBEAM);
3453 break;
3454
3455 case wRefBeam:
3456 def = defend(wpnId, power, edefREFBEAM);
3457 break;
3458
3459 case wRefMagic:
3460 def = defend(wpnId, power, edefREFMAGIC);
3461 break;
3462
3463 case wRefFireball:
3464 def = defend(wpnId, power, edefREFBALL);
3465 break;
3466
3467 case wRefRock:
3468 def = defend(wpnId, power, edefREFROCK);
3469 break;
3470
3471 case wStomp:
3472 def = defend(wpnId, power, edefSTOMP);
3473 break;
3474
3475 case wCByrna:
3476 def = defend(wpnId, power, edefBYRNA);
3477 break;
3478
3479 case wScript1:
3480 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3481 else def = defend(wpnId, power, edefSCRIPT);
3482 break;
3483
3484 case wScript2:
3485 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3486 else def = defend(wpnId, power, edefSCRIPT);
3487 break;
3488
3489 case wScript3:
3490 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3491 else def = defend(wpnId, power, edefSCRIPT);
3492 break;
3493
3494 case wScript4:
3495 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3496 else def = defend(wpnId, power, edefSCRIPT);
3497 break;
3498
3499 case wScript5:
3500 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3501 else def = defend(wpnId, power, edefSCRIPT);
3502 break;
3503
3504 case wScript6:
3505 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3506 else def = defend(wpnId, power, edefSCRIPT);
3507 break;
3508
3509 case wScript7:
3510 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3511 else def = defend(wpnId, power, edefSCRIPT);
3512 break;
3513
3514 case wScript8:
3515 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3516 else def = defend(wpnId, power, edefSCRIPT);
3517 break;
3518
3519 case wScript9:
3520 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3521 else def = defend(wpnId, power, edefSCRIPT);
3522 break;
3523
3524 case wScript10:
3525 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3526 else def = defend(wpnId, power, edefSCRIPT);
3527 break;
3528
3529 case wWhistle:
3530 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3531 else break;
3532 break;
3533
3534 case wRefArrow:
3535 def = defend(wpnId, power, edefREFARROW);
3536 break;
3537 case wRefFire:
3538 def = defend(wpnId, power, edefREFFIRE);
3539 break;
3540 case wRefFire2:
3541 def = defend(wpnId, power, edefREFFIRE2);
3542 break;
3543
3544 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3545 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3546 //of the ten if the quest version is lower than N.
3547 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3548 //such as bool UseSeparatedScriptDefences. hah.
3549 default:
3550 //if(wpnId>=wScript1 && wpnId<=wScript10)
3551 // {
3552 // def = defend(wpnId, power, edefSCRIPT);
3553 // }
3554 // }
3555
3556 break;
3557 }
3558
3559 return def;
3560 }
3561
3562 // take damage or ignore it
3563 // -1: damage (if any) dealt
3564 // 1: blocked
3565 // 0: weapon passes through unhindered
3566 264485 int32_t enemy::takehit(weapon *w, weapon* realweap)
3567 {
3568
2/4
✓ Branch 0 taken 264485 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 264485 times.
264485 if(fallclk||drownclk) return 0;
3569
2/2
✓ Branch 0 taken 69389 times.
✓ Branch 1 taken 195096 times.
264485 if(!realweap) realweap = w;
3570 264485 int32_t wpnId = w->id;
3571 264485 int32_t power = w->power;
3572 264485 int32_t wpnx = w->x;
3573 264485 int32_t wpny = w->y;
3574 264485 int32_t enemyHitWeapon = w->parentitem;
3575 int32_t wpnDir;
3576 264485 int32_t parent_item = w->parentitem;
3577
3578
2/2
✓ Branch 0 taken 264370 times.
✓ Branch 1 taken 115 times.
264485 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3579 {
3580 115 wpnId = w->useweapon;
3581 115 }
3582
3583 // If it's a boomerang that just bounced, use the opposite direction;
3584 // otherwise, it might bypass a shield. This probably won't handle
3585 // every case correctly, but it's better than having shields simply
3586 // not work against boomerangs.
3587
8/8
✓ Branch 0 taken 25075 times.
✓ Branch 1 taken 239410 times.
✓ Branch 2 taken 15575 times.
✓ Branch 3 taken 9500 times.
✓ Branch 4 taken 14357 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3305 times.
✓ Branch 7 taken 11052 times.
264485 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3588 11052 wpnDir = oppositeDir[w->dir];
3589 else
3590 253433 wpnDir = w->dir;
3591
3592
5/8
✓ Branch 0 taken 264485 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264485 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 264485 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8172 times.
✓ Branch 7 taken 271943 times.
264485 if(dying || clk<0 || hclk>0 || superman)
3593 8172 return 0;
3594
3595 //Prevent boomerang from writing to hitby[] for more than one frame.
3596 //This also prevents stunlock.
3597 //if ( stunclk > 0 ) return 0;
3598 //this needs a rule for boomerangs that cannot stunlock!
3599 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3600 //sigh.
3601
3602 271943 int32_t ret = -1;
3603
3604 // This obscure quest rule...
3605
5/6
✓ Branch 0 taken 91703 times.
✓ Branch 1 taken 180240 times.
✓ Branch 2 taken 88200 times.
✓ Branch 3 taken 3503 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88200 times.
271943 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3606 {
3607 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3608 3503 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3609 3503 wpnDir=zc_oldrand()&3;
3610
3611
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3036 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3503 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3612 {
3613 189 wpnDir=down;
3614 189 }
3615
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2751 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3314 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3616 {
3617 285 wpnDir=right;
3618 285 }
3619
4/4
✓ Branch 0 taken 2342 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2064 times.
3029 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3620 {
3621 2064 wpnDir=up;
3622 2064 }
3623 else
3624 {
3625 965 wpnDir=left;
3626 }
3627 3503 }
3628
3629 271943 int32_t xdir = dir;
3630 271943 shieldCanBlock=false;
3631
3632
4/4
✓ Branch 0 taken 260663 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 257896 times.
272671 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3633
6/6
✓ Branch 0 taken 18173 times.
✓ Branch 1 taken 15406 times.
✓ Branch 2 taken 25948 times.
✓ Branch 3 taken 247354 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 247296 times.
260663 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3634
4/4
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 246312 times.
✓ Branch 2 taken 728 times.
✓ Branch 3 taken 245584 times.
247296 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3635 )
3636 // The hammer should already be dealt with by subclasses (Walker etc.)
3637 {
3638
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5748 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 1488 times.
45891 switch(wpnId)
3639 {
3640 // Weapons which shields protect against
3641 case wSword:
3642 case wWand:
3643
2/2
✓ Branch 0 taken 5746 times.
✓ Branch 1 taken 2 times.
5750 if(Hero.getCharging()>0)
3644 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3645
3646 [[fallthrough]];
3647 case wHookshot:
3648 case wHSHandle:
3649 case wBrang:
3650 6120 shieldCanBlock=true;
3651 6458 break;
3652
3653 case wBeam:
3654 case wRefBeam:
3655 // Mirror shielded enemies!
3656 #if 0
3657 if(false /*flags2&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3658 {
3659 if(wpnId>wEnemyWeapons)
3660 return 0;
3661
3662 sfx(WAV_CHINK,pan(int32_t(x)));
3663 return 1;
3664 }
3665
3666 #endif
3667
3668 [[fallthrough]];
3669 case wRefRock:
3670 case wRefFireball:
3671 case wMagic:
3672 #if 0
3673 if(false /*flags2&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3674 {
3675 sfx(WAV_CHINK,pan(int32_t(x)));
3676 return 3;
3677 }
3678
3679 #endif
3680
3681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367 times.
367 if(wpnId>wEnemyWeapons)
3682 return 0;
3683
3684 [[fallthrough]];
3685 case wArrow:
3686 380 case wRefArrow:
3687 default:
3688 1868 shieldCanBlock=true;
3689 1868 break;
3690
3691 // Bombs
3692 case wSBomb:
3693 case wBomb:
3694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3695 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3696 {
3697 sfx(WAV_CHINK,pan(int32_t(x)));
3698 return 0;
3699 }
3700 else break;
3701
3702 // Weapons which ignore shields
3703 case wWhistle:
3704 case wHammer:
3705 2 break;
3706
3707 // Weapons which shouldn't be removed by shields
3708 case wLitBomb:
3709 case wLitSBomb:
3710 case wWind:
3711 case wPhantom:
3712 case wSSparkle:
3713 case wBait:
3714 864 return 0;
3715
3716 case wFire:
3717 case wRefFire:
3718 case wRefFire2:
3719 ;
3720 680 }
3721 8670 }
3722
3723
8/8
✓ Branch 0 taken 103171 times.
✓ Branch 1 taken 97394 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27424 times.
✓ Branch 5 taken 25029 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9056 times.
265534 switch(wpnId)
3724 {
3725 case wWhistle: //No longer completely ignore whistle weapons! -Z
3726 {
3727
3728
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3729 {
3730 423 return 0; break;
3731 }
3732 else
3733 {
3734 w->power = power = itemsbuf[parent_item].misc5;
3735
3736 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3737
3738 if(def <= 0)
3739 {
3740 if ( def == -2 ) hp -= hp;
3741 else hp -= power;
3742 return def;
3743 }
3744 break;
3745 }
3746 break;
3747 }
3748
3749 case wPhantom:
3750 270 return 0;
3751
3752 case wLitBomb:
3753 case wLitSBomb:
3754 case wBait:
3755 case wWind:
3756 case wSSparkle:
3757 103171 return 0;
3758
3759 case wFSparkle:
3760
3761 // Only take sparkle damage if the sparkle's parent item is not
3762 // defended against.
3763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27424 times.
27424 if(enemyHitWeapon > -1)
3764 {
3765 27424 int32_t p = 0;
3766 27424 int32_t f = itemsbuf[enemyHitWeapon].family;
3767
3768
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27424 times.
27424 switch(f)
3769 {
3770 case itype_arrow:
3771 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3772
3773 break;
3774
3775 case itype_cbyrna:
3776 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3777
3778 break;
3779
3780 case itype_brang:
3781
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26955 times.
27424 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3782
3783 469 break;
3784
3785 default:
3786 return 0;
3787 }
3788 469 }
3789
3790 469 wpnId = wSword;
3791 469 power = game->get_hero_dmgmult()>>1;
3792 469 goto fsparkle;
3793 break;
3794
3795 case wBrang:
3796 {
3797 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3798 25029 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3799 //preventing stunlock might be best, here. -Z
3800
2/2
✓ Branch 0 taken 5467 times.
✓ Branch 1 taken 19562 times.
25029 if(def >= 0) return def;
3801
3802 // Not hurt by 0-damage weapons
3803
2/2
✓ Branch 0 taken 3188 times.
✓ Branch 1 taken 16374 times.
19562 if(!(flags & guy_bhit))
3804 {
3805 16374 stunclk=160;
3806
3807
3/4
✓ Branch 0 taken 16374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1305 times.
✓ Branch 3 taken 15069 times.
16374 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3808 {
3809
1/2
✓ Branch 0 taken 1305 times.
✗ Branch 1 not taken.
1305 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3810 1305 goto hitclock;
3811 }
3812
3813 15069 break;
3814 }
3815
3816
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 2793 times.
3188 if(!power)
3817
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3818 else
3819 395 hp-=power;
3820
3821 3188 goto hitclock;
3822 }
3823
3824 case wHookshot:
3825 {
3826 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3827 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3828
3829
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3830
3831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3832
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3833 {
3834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3835 1625 stunclk=160;
3836
3837
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3838 {
3839
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3840 549 goto hitclock;
3841 }
3842
3843 1076 break;
3844 }
3845
3846
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3847 else
3848 45 hp-=power;
3849
3850 148 goto hitclock;
3851 }
3852 break;
3853
3854 case wHSHandle:
3855 {
3856
3/4
✓ Branch 0 taken 9056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8533 times.
9056 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3857 523 return 0;
3858
3859
3/4
✓ Branch 0 taken 6093 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8533 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3860
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3861
3862 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3863
6/8
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2285 times.
10245 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3864
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3889 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2177 times.
2787 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3865 2177 return 0;
3866
3867 12102 power = game->get_hero_dmgmult();
3868 12571 }
3869
3870 fsparkle:
3871
3872 [[fallthrough]];
3873 default:
3874 // Work out the defenses!
3875 {
3876 98473 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3877
3878
2/2
✓ Branch 0 taken 26468 times.
✓ Branch 1 taken 72005 times.
98473 if(def >= 0)
3879 26468 return def;
3880
2/2
✓ Branch 0 taken 71545 times.
✓ Branch 1 taken 460 times.
72005 else if(def == -2)
3881 {
3882 460 ret = 0;
3883 460 }
3884 }
3885
3886
2/2
✓ Branch 0 taken 72003 times.
✓ Branch 1 taken 2 times.
144010 if(!power)
3887 {
3888
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3889 2 hp-=1;
3890 else
3891 {
3892 // Don't make a long chain of 'stun' hits
3893 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3894 return 1;
3895
3896
3897 if(!switch_hooked)
3898 stunclk=160;
3899 break;
3900 }
3901 2 }
3902 72003 else hp-=power;
3903
3904 hitclock:
3905 77206 hclk=33;
3906
3907 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3908
2/2
✓ Branch 0 taken 34517 times.
✓ Branch 1 taken 42689 times.
77206 if((dir&2)==(w->dir&2))
3909 {
3910 42689 sclk=(w->dir<<8)+16;
3911 42689 }
3912 77206 }
3913
3914
5/6
✓ Branch 0 taken 73789 times.
✓ Branch 1 taken 19562 times.
✓ Branch 2 taken 21974 times.
✓ Branch 3 taken 71377 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21974 times.
93351 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3915 {
3916 21974 fading=fade_blue_poof;
3917 21974 }
3918
3919
6/6
✓ Branch 0 taken 88418 times.
✓ Branch 1 taken 4933 times.
✓ Branch 2 taken 46745 times.
✓ Branch 3 taken 41673 times.
✓ Branch 4 taken 2155 times.
✓ Branch 5 taken 44590 times.
93351 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3920 {
3921
2/2
✓ Branch 0 taken 7081 times.
✓ Branch 1 taken 7 times.
7088 if( hitsfx > 0 ) //user-set hit sound.
3922 {
3923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7081 times.
7081 if (!dying) //don't play the hit sound on death! -Z
3924 7081 sfx(hitsfx, pan(int32_t(x)));
3925 7081 }
3926 7 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3927 7088 }
3928 else //2.50.2 or earlier
3929 {
3930 86263 sfx(WAV_EHIT, pan(int32_t(x)));
3931 86263 sfx(hitsfx, pan(int32_t(x)));
3932 }
3933
2/2
✓ Branch 0 taken 93322 times.
✓ Branch 1 taken 29 times.
93351 if(family==eeGUY)
3934 29 sfx(WAV_EDEAD, pan(int32_t(x)));
3935
3936 // Penetrating weapons
3937
4/4
✓ Branch 0 taken 91490 times.
✓ Branch 1 taken 1861 times.
✓ Branch 2 taken 84591 times.
✓ Branch 3 taken 8760 times.
93351 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3938 {
3939 8760 int32_t item=enemyHitWeapon;
3940
3941
2/2
✓ Branch 0 taken 1599 times.
✓ Branch 1 taken 7161 times.
8760 if(wpnId==wArrow)
3942 {
3943 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3944
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1599 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].family == itype_arrow))
3945 379 return 0;
3946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1220 times.
1220 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3947 //if(item<0)
3948 else
3949 1220 item=current_item_id(itype_arrow);
3950 1220 }
3951
3952 else
3953 {
3954
3955 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3956
3/6
✓ Branch 0 taken 7143 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7143 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7161 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].family == itype_sword))
3957 return 0;
3958
3959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7161 times.
7161 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3960 else
3961 //if(item<0)
3962 7161 item=current_item_id(itype_sword);
3963 }
3964 8381 }
3965
3966 92972 return ret;
3967 268835 }
3968
3969 61495234 bool enemy::dont_draw()
3970 {
3971
6/6
✓ Branch 0 taken 61032448 times.
✓ Branch 1 taken 462786 times.
✓ Branch 2 taken 60961541 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 172044 times.
✓ Branch 5 taken 60860404 times.
61495234 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3972 634830 return true;
3973
3974
2/2
✓ Branch 0 taken 1371477 times.
✓ Branch 1 taken 59488927 times.
60860404 if(flags&guy_invisible)
3975 1371477 return true;
3976
3977
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 59488495 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
59488927 if(flags&guy_lens_only && !lensclk)
3978 return true;
3979
3980 59488927 return false;
3981 61495234 }
3982
3983 #define DRAW_NORMAL 2
3984 #define DRAW_CLOAKED 1
3985 #define DRAW_INVIS 0
3986 // base drawing function to be used by all derived classes instead of
3987 // sprite::draw()
3988 44703810 void enemy::draw(BITMAP *dest)
3989 {
3990 44703810 didScriptThisFrame = false; //Since there's no better place to put it
3991
6/6
✓ Branch 0 taken 43940405 times.
✓ Branch 1 taken 763405 times.
✓ Branch 2 taken 43857755 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 314567 times.
✓ Branch 5 taken 43625838 times.
44703810 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3992 1077972 return;
3993
2/2
✓ Branch 0 taken 2767665 times.
✓ Branch 1 taken 40858173 times.
43625838 if(flags&guy_invisible)
3994 2767665 return;
3995
3996 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
3997 // be cloaked if they have "invisible displays as cloaked" checked.
3998
3999 40858173 byte canSee = DRAW_NORMAL;
4000 //Enemy specific stuff
4001
2/2
✓ Branch 0 taken 40857009 times.
✓ Branch 1 taken 1164 times.
40858173 if ( editorflags & ENEMY_FLAG1 )
4002 {
4003 1164 canSee = DRAW_INVIS;
4004
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4005
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4006 {
4007 if (game->item[dmisc13])
4008 {
4009 canSee = DRAW_NORMAL;
4010 }
4011 //else if ( lensclk && getlensid.flags SHOWINVIS )
4012 //{
4013 //
4014 //}
4015 //else
4016 //{
4017 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4018 // //otherwisem invisible
4019 //}
4020 }
4021 1164 }
4022 //Room specific
4023
2/2
✓ Branch 0 taken 38686974 times.
✓ Branch 1 taken 2171199 times.
40858173 if (tmpscr->flags3&fINVISROOM)
4024 {
4025
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4027 2171199 }
4028 //Lens check
4029
2/2
✓ Branch 0 taken 27345 times.
✓ Branch 1 taken 40830828 times.
40858173 if (lensclk)
4030 {
4031
2/2
✓ Branch 0 taken 26913 times.
✓ Branch 1 taken 432 times.
27345 if(flags&guy_lens_only)
4032 {
4033
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4034 432 }
4035 27345 }
4036 else
4037 {
4038
2/2
✓ Branch 0 taken 40757412 times.
✓ Branch 1 taken 73416 times.
40830828 if(flags&guy_lens_only)
4039 73416 canSee = DRAW_INVIS;
4040 }
4041
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 40783593 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
40858173 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4042
3/4
✓ Branch 0 taken 40557589 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40557589 times.
✗ Branch 3 not taken.
40858173 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4043
4044
2/2
✓ Branch 0 taken 40783593 times.
✓ Branch 1 taken 74580 times.
40858173 if (canSee == DRAW_INVIS)
4045 74580 return;
4046
4047
4/4
✓ Branch 0 taken 40781287 times.
✓ Branch 1 taken 2306 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40781280 times.
40783593 if(fallclk||drownclk)
4048 {
4049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2313 times.
2313 if (canSee == DRAW_CLOAKED)
4050 {
4051 sprite::drawcloaked(dest);
4052 }
4053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2313 times.
2313 else if (canSee == DRAW_NORMAL)
4054 {
4055 2313 sprite::draw(dest);
4056 2313 }
4057 2313 return;
4058 }
4059 40781280 int32_t cshold=cs;
4060
4061
2/2
✓ Branch 0 taken 901687 times.
✓ Branch 1 taken 39879593 times.
40781280 if(dying)
4062 {
4063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901687 times.
901687 if(clk2>=19)
4064 {
4065 if(!(clk2&2))
4066 {
4067 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4068 if (canSee == DRAW_CLOAKED)
4069 {
4070 sprite::drawcloaked(dest);
4071 }
4072 else if (canSee == DRAW_NORMAL)
4073 {
4074 sprite::draw(dest);
4075 }
4076 }
4077 return;
4078 }
4079
4080 901687 flip = 0;
4081 901687 tile = wpnsbuf[spr_death].tile;
4082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 901687 times.
901687 if ( do_animation )
4083 {
4084 901687 int32_t offs = 0;
4085
2/2
✓ Branch 0 taken 850820 times.
✓ Branch 1 taken 50867 times.
901687 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4086 {
4087
2/2
✓ Branch 0 taken 49251 times.
✓ Branch 1 taken 1616 times.
50867 if(clk2 > 2)
4088 {
4089 1616 spr_death_anim_clk=0;
4090 1616 clk2=1;
4091
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1602 times.
1616 if(hp > -1000)
4092 1602 death_sfx();
4093 1616 }
4094
4/4
✓ Branch 0 taken 38168 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 37766 times.
50867 if(clk2==1 && spr_death_anim_clk>-1)
4095 {
4096 37766 ++clk2;
4097
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35384 times.
37766 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4098
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 37745 times.
37766 spr_death_anim_frm *= zc_max(1,txsz);
4099 37766 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4100
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37690 times.
37766 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4101
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35384 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 37764 times.
✓ Branch 4 taken 36168 times.
✓ Branch 5 taken 1598 times.
37766 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4102 {
4103 1598 spr_death_anim_clk=-1;
4104 1598 clk2=1;
4105 1598 }
4106 37766 }
4107 50867 tile += spr_death_anim_frm;
4108 50867 }
4109
2/2
✓ Branch 0 taken 313513 times.
✓ Branch 1 taken 537307 times.
850820 else if(BSZ)
4110 {
4111
2/2
✓ Branch 0 taken 246522 times.
✓ Branch 1 taken 66991 times.
313513 offs = zc_min((15-clk2)/3,4);
4112 313513 }
4113
4/4
✓ Branch 0 taken 358283 times.
✓ Branch 1 taken 179024 times.
✓ Branch 2 taken 179013 times.
✓ Branch 3 taken 179270 times.
537307 else if(clk2>6 && clk2<=12)
4114 {
4115 179270 offs = 1;
4116 179270 }
4117
4118
2/2
✓ Branch 0 taken 455054 times.
✓ Branch 1 taken 446633 times.
901687 if(offs)
4119 {
4120
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 446183 times.
446633 offs *= zc_max(1,txsz);
4121 446633 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4122
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 446195 times.
446633 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4123 446633 }
4124 901687 tile += offs;
4125 901687 }
4126
4127
6/6
✓ Branch 0 taken 850820 times.
✓ Branch 1 taken 50867 times.
✓ Branch 2 taken 537307 times.
✓ Branch 3 taken 313513 times.
✓ Branch 4 taken 189344 times.
✓ Branch 5 taken 347963 times.
901687 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4128 553724 cs = wpnsbuf[spr_death].csets&15;
4129 else
4130 347963 cs = (((clk2+5)>>1)&3)+6;
4131 901687 }
4132
3/4
✓ Branch 0 taken 1189488 times.
✓ Branch 1 taken 38690105 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1189488 times.
39879593 else if(hclk>0 && getCanFlicker())
4133 {
4134 1189488 cs = getFlashingCSet();
4135 1189488 }
4136 //draw every other frame for flickering enemies
4137
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40533249 times.
40781280 if (is_hitflickerframe(false))
4138 {
4139
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4140
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4141 {
4142 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4143 sprite_flicker_color = temp_flicker_color;
4144 sprite::draw(dest);
4145 }
4146 248031 }
4147 else
4148 {
4149
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40308087 times.
40533249 if (canSee == DRAW_CLOAKED)
4150 {
4151 225162 sprite::drawcloaked(dest);
4152 225162 }
4153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40308087 times.
40308087 else if (canSee == DRAW_NORMAL)
4154 {
4155
1/2
✓ Branch 0 taken 40308087 times.
✗ Branch 1 not taken.
40308087 if ( frozenclock < 0 )
4156 {
4157 if ( frozentile > 0 ) tile = frozentile;
4158 loadpalset(csBOSS,frozencset);
4159 }
4160 40308087 sprite::draw(dest);
4161 40308087 }
4162 }
4163 40781280 cs=cshold;
4164 44703810 }
4165
4166 //old zc bosses
4167 40752657 void enemy::drawzcboss(BITMAP *dest)
4168 {
4169 40752657 didScriptThisFrame = false; //Since there's no better place to put it
4170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40752657 times.
40752657 if(dont_draw())
4171 return;
4172
4173 40752657 int32_t cshold=cs;
4174
4175
2/2
✓ Branch 0 taken 781746 times.
✓ Branch 1 taken 39970911 times.
40752657 if(dying)
4176 {
4177
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 777786 times.
781746 if(clk2>=19)
4178 {
4179
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4180 1980 sprite::drawzcboss(dest);
4181
4182 3960 return;
4183 }
4184
4185 777786 flip = 0;
4186 777786 tile = wpnsbuf[spr_death].tile;
4187
4188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777786 times.
777786 if ( do_animation )
4189 {
4190
2/2
✓ Branch 0 taken 773270 times.
✓ Branch 1 taken 4516 times.
777786 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4191 {
4192
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4193 {
4194 6 spr_death_anim_clk=0;
4195 6 clk2=1;
4196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4197 6 death_sfx();
4198 6 }
4199
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4200 {
4201 76 ++clk2;
4202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4204 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4206
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4207 {
4208 2 spr_death_anim_clk=-1;
4209 2 clk2=1;
4210 2 }
4211 76 }
4212 4516 tile += spr_death_anim_frm;
4213 4516 }
4214
2/2
✓ Branch 0 taken 276492 times.
✓ Branch 1 taken 496778 times.
773270 else if(BSZ)
4215
2/2
✓ Branch 0 taken 217484 times.
✓ Branch 1 taken 59008 times.
276492 tile += zc_min((15-clk2)/3,4);
4216
4/4
✓ Branch 0 taken 331149 times.
✓ Branch 1 taken 165629 times.
✓ Branch 2 taken 165472 times.
✓ Branch 3 taken 165677 times.
496778 else if(clk2>6 && clk2<=12)
4217 165677 ++tile;
4218 777786 }
4219
4220
6/6
✓ Branch 0 taken 773270 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 496778 times.
✓ Branch 3 taken 276492 times.
✓ Branch 4 taken 184034 times.
✓ Branch 5 taken 312744 times.
777786 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4221 465042 cs = wpnsbuf[spr_death].csets&15;
4222 else
4223 312744 cs = (((clk2+5)>>1)&3)+6;
4224 777786 }
4225
2/2
✓ Branch 0 taken 38770797 times.
✓ Branch 1 taken 1200114 times.
39970911 else if(hclk>0)
4226 {
4227 1200114 cs = getFlashingCSet();
4228 1200114 }
4229
4230
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38703078 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40756240 if((tmpscr->flags3&fINVISROOM) &&
4231
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4233 7543 lensclk) && family!=eeGANON)
4234 {
4235 7543 sprite::drawcloaked(dest);
4236 7543 }
4237 else
4238 {
4239
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40717681 times.
40741154 if (is_hitflickerframe(true))
4240 {
4241
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4242
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4243 {
4244 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4245 sprite_flicker_color = temp_flicker_color;
4246 sprite::drawzcboss(dest);
4247 }
4248 23473 }
4249 else
4250 40717681 sprite::drawzcboss(dest);
4251 }
4252
4253 40748697 cs=cshold;
4254 40752657 }
4255
4256
4257 // similar to the overblock function--can do up to a 32x32 sprite
4258 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4259 323235 void enemy::drawblock(BITMAP *dest,int32_t mask)
4260 {
4261 323235 int32_t thold=tile;
4262 323235 int32_t t1=tile;
4263 323235 int32_t t2=tile+20;
4264 323235 int32_t t3=tile+1;
4265 323235 int32_t t4=tile+21;
4266
4267
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323235 times.
323235 switch(mask)
4268 {
4269 case 1:
4270 enemy::drawzcboss(dest);
4271 break;
4272
4273 case 3:
4274 if(flip&2)
4275 zc_swap(t1,t2);
4276
4277 tile=t1;
4278 enemy::drawzcboss(dest);
4279 tile=t2;
4280 yofs+=16;
4281 enemy::drawzcboss(dest);
4282 yofs-=16;
4283 break;
4284
4285 case 5:
4286 t2=tile+1;
4287
4288 if(flip&1)
4289 zc_swap(t1,t2);
4290
4291 tile=t1;
4292 enemy::drawzcboss(dest);
4293 tile=t2;
4294 xofs+=16;
4295 enemy::drawzcboss(dest);
4296 xofs-=16;
4297 break;
4298
4299 case 15:
4300
2/2
✓ Branch 0 taken 316479 times.
✓ Branch 1 taken 6756 times.
323235 if(flip&1)
4301 {
4302 6756 zc_swap(t1,t3);
4303 6756 zc_swap(t2,t4);
4304 6756 }
4305
4306
1/2
✓ Branch 0 taken 323235 times.
✗ Branch 1 not taken.
323235 if(flip&2)
4307 {
4308 zc_swap(t1,t2);
4309 zc_swap(t3,t4);
4310 }
4311
4312 323235 tile=t1;
4313 323235 enemy::drawzcboss(dest);
4314 323235 tile=t2;
4315 323235 yofs+=16;
4316 323235 enemy::drawzcboss(dest);
4317 323235 yofs-=16;
4318 323235 tile=t3;
4319 323235 xofs+=16;
4320 323235 enemy::drawzcboss(dest);
4321 323235 tile=t4;
4322 323235 yofs+=16;
4323 323235 enemy::drawzcboss(dest);
4324 323235 xofs-=16;
4325 323235 yofs-=16;
4326 323235 break;
4327 }
4328
4329 323235 tile=thold;
4330 323235 }
4331
4332 20178752 void enemy::drawshadow(BITMAP *dest, bool translucent)
4333 {
4334
4/4
✓ Branch 0 taken 18172445 times.
✓ Branch 1 taken 2006307 times.
✓ Branch 2 taken 406089 times.
✓ Branch 3 taken 17766356 times.
20178752 if(dont_draw() || isSideViewGravity())
4335 {
4336 2412396 return;
4337 }
4338
4339
2/2
✓ Branch 0 taken 326866 times.
✓ Branch 1 taken 17439490 times.
17766356 if(dying)
4340 {
4341 326866 return;
4342 }
4343
4344
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 15721241 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 17092480 times.
17439490 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4345 17439490 (darkroom))
4346 {
4347 347010 return;
4348 }
4349 else
4350 {
4351
4/4
✓ Branch 0 taken 16518574 times.
✓ Branch 1 taken 573906 times.
✓ Branch 2 taken 16471201 times.
✓ Branch 3 taken 47373 times.
17092480 if(enemycanfall(id, false) && shadowtile == 0)
4352 47373 shadowtile = wpnsbuf[spr_shadow].tile;
4353
4354
5/6
✓ Branch 0 taken 16154116 times.
✓ Branch 1 taken 938364 times.
✓ Branch 2 taken 16154116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15580210 times.
✓ Branch 5 taken 573906 times.
17092480 if(z>0 || fakez>0 || !enemycanfall(id, false))
4355 {
4356
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1511995 times.
1512270 if(!shadow_overpit(this))
4357 1511995 sprite::drawshadow(dest,translucent);
4358 1512270 }
4359 }
4360 20178752 }
4361
4362 129181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4363 {
4364 129181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4365
4366
1/2
✓ Branch 0 taken 129181 times.
✗ Branch 1 not taken.
129181 if(sub!=NULL)
4367 {
4368 129181 xofs-=mx;
4369 129181 yofs-=my;
4370 129181 enemy::draw(sub);
4371 129181 xofs+=mx;
4372 129181 yofs+=my;
4373 129181 destroy_bitmap(sub);
4374 129181 }
4375 else
4376 enemy::draw(dest);
4377 129181 }
4378
4379 9 void enemy::init_size_flags()
4380 {
4381
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4382
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4383
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4384
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4385
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (((SIZEflags & guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4386
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4387
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4388
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & guyflagOVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4389
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & guyflagOVERRIDE_DRAW_Y_OFFSET) != 0)
4390 {
4391 yofs = (int32_t)d->yofs;
4392 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4393 }
4394
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & guyflagOVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4395 9 }
4396
4397 // override hit detection to check for invicibility, stunned, etc
4398 112151935 bool enemy::hit()
4399 {
4400
4/4
✓ Branch 0 taken 110828636 times.
✓ Branch 1 taken 1323299 times.
✓ Branch 2 taken 109033740 times.
✓ Branch 3 taken 1794896 times.
112151935 if(dying || hclk>0) return false;
4401 109033740 return sprite::hit();
4402 112151935 }
4403 730351 bool enemy::hit(sprite *s)
4404 {
4405
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4406 713374 return sprite::hit(s);
4407 730351 }
4408
4409 44501745 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4410 {
4411
2/2
✓ Branch 0 taken 3919072 times.
✓ Branch 1 taken 40582673 times.
44501745 if(!hit()) return false;
4412 40582673 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4413 44501745 }
4414 78011 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4415 {
4416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78011 times.
78011 if(!hit()) return false;
4417 78011 return sprite::hit(tx,ty,txsz2,tysz2);
4418 78011 }
4419
4420 11132898 bool enemy::hit(weapon *w)
4421 {
4422
2/2
✓ Branch 0 taken 1172363 times.
✓ Branch 1 taken 9960535 times.
11132898 if(!hit()) return false;
4423
4424
2/2
✓ Branch 0 taken 6645972 times.
✓ Branch 1 taken 3314563 times.
9960535 if (replay_version_check(0, 14))
4425 {
4426
4/6
✓ Branch 0 taken 6421665 times.
✓ Branch 1 taken 224307 times.
✓ Branch 2 taken 6421665 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6421665 times.
✗ Branch 5 not taken.
6645972 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4427 224307 return false;
4428 6421665 return sprite::hit(w);
4429 }
4430 3314563 return w->hit(this);
4431 11132898 }
4432
4433 9456450 bool enemy::can_pitfall(bool checkspawning)
4434 {
4435
4/4
✓ Branch 0 taken 9436662 times.
✓ Branch 1 taken 19788 times.
✓ Branch 2 taken 9426007 times.
✓ Branch 3 taken 30443 times.
9456450 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4436
2/2
✓ Branch 0 taken 9408347 times.
✓ Branch 1 taken 17660 times.
9426007 switch(guysbuf[id&0xFFF].family)
4437 {
4438 case eeAQUA:
4439 case eeDIG:
4440 case eeDONGO:
4441 case eeFAIRY:
4442 case eeGANON:
4443 case eeGHOMA:
4444 case eeGLEEOK:
4445 case eeGUY:
4446 case eeLANM:
4447 case eeMANHAN:
4448 case eeMOLD:
4449 case eeNONE:
4450 case eePATRA:
4451 case eeZORA:
4452 17660 return false; //Disallowed types
4453 default:
4454 9408347 return true;
4455 }
4456 9456450 }
4457 //Handle death
4458 37824270 void enemy::try_death(bool force_kill)
4459 {
4460
8/8
✓ Branch 0 taken 37769243 times.
✓ Branch 1 taken 55027 times.
✓ Branch 2 taken 37769232 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43498 times.
✓ Branch 5 taken 37725734 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43497 times.
37824270 if(!dying && (force_kill || (hp<=0 && !immortal)))
4461 {
4462 43508 std::vector<int32_t> &ev = FFCore.eventData;
4463 43508 ev.clear();
4464 43508 ev.push_back(10000);
4465 43508 ev.push_back(getUID());
4466
4467 43508 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4468 43508 bool isSaved = !ev[0];
4469 43508 ev.clear();
4470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43508 times.
43508 if(isSaved) return;
4471
4472
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 43460 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 42 times.
43508 if(itemguy && (hasitem&2)!=0)
4473 {
4474
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 42 times.
89 for(int32_t i=0; i<items.Count(); i++)
4475 {
4476
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 42 times.
47 if(((item*)items.spr(i))->pickup&ipENEMY)
4477 {
4478
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 1 times.
42 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4479 {
4480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4481 {
4482 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4483 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4484 }
4485 else
4486 {
4487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(extend >= 3)
4488 {
4489 items.spr(i)->x = x+(txsz-1)*8;
4490 items.spr(i)->y = y-2+(tysz-1)*8;
4491 }
4492 else
4493 {
4494 1 items.spr(i)->x = x;
4495 1 items.spr(i)->y = y - 2;
4496 }
4497 }
4498 1 items.spr(i)->z = z;
4499 1 items.spr(i)->fakez = fakez;
4500 1 }
4501 else
4502 {
4503 41 items.spr(i)->x = x;
4504 41 items.spr(i)->y = y - 2;
4505 }
4506 42 }
4507 47 }
4508 42 }
4509
4510 43508 dying=true;
4511
4512
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43476 times.
43508 if(fading==fade_flash_die)
4513 32 clk2=19+18*4;
4514 else
4515 {
4516 43476 clk2 = BSZ ? 15 : 19;
4517
4518
2/2
✓ Branch 0 taken 21056 times.
✓ Branch 1 taken 22420 times.
43476 if(fading!=fade_blue_poof)
4519 22420 fading=0;
4520 }
4521
4522
2/2
✓ Branch 0 taken 43460 times.
✓ Branch 1 taken 48 times.
43508 if(itemguy)
4523 {
4524 48 hasitem&=~2;
4525 48 item_set=0;
4526 48 }
4527
4528
6/6
✓ Branch 0 taken 42454 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 33769 times.
✓ Branch 3 taken 8685 times.
✓ Branch 4 taken 1413 times.
✓ Branch 5 taken 32356 times.
43508 if(currscr<128 && count_enemy && !script_spawned)
4529 32356 game->guys[(currmap<<7)+currscr]-=1;
4530 43508 }
4531 37824270 }
4532
4533 // --==**==--
4534
4535 // Movement routines that can be used by derived classes as needed
4536
4537 // --==**==--
4538
4539 555845 void enemy::fix_coords(bool bound)
4540 {
4541
1/2
✓ Branch 0 taken 555845 times.
✗ Branch 1 not taken.
555845 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 555845 times.
555845 if(moveflags & move_ignore_screenedge) bound = false;
4543
4544
4545
2/2
✓ Branch 0 taken 81680 times.
✓ Branch 1 taken 474165 times.
555845 if(bound)
4546 {
4547
1/2
✓ Branch 0 taken 474165 times.
✗ Branch 1 not taken.
474165 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4548 {
4549
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
474165 x=vbound(x, 0_zf, (( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256_zf -((txsz-1)*16)) : 240_zf));
4550
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 474163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
474165 y=vbound(y, 0_zf,(( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176_zf -((txsz-1)*16)) : 160_zf));
4551 474165 }
4552 else
4553 {
4554 x=vbound(x, 0_zf,240_zf);
4555 y=vbound(y, 0_zf,160_zf);
4556 }
4557 474165 }
4558
4559
6/10
✓ Branch 0 taken 554831 times.
✓ Branch 1 taken 1014 times.
✓ Branch 2 taken 555845 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 555845 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 555845 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 555845 times.
555845 if(!OUTOFBOUNDS)
4560 {
4561 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
4562
4563 if(isSideViewGravity())
4564 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
4565 else
4566 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
4567 */
4568 555845 do_fix(x, 16, true);
4569
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 554831 times.
555845 if(isSideViewGravity())
4570 1014 do_fix(y,8,true);
4571 554831 else do_fix(y,16,true);
4572 555845 }
4573 555845 }
4574 9156 bool enemy::cannotpenetrate()
4575 {
4576
4/4
✓ Branch 0 taken 8975 times.
✓ Branch 1 taken 181 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8937 times.
9156 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4577 }
4578
4579 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4580 {
4581 bool ok;
4582 562 int32_t dx = 0, dy = 0;
4583 562 int32_t sv = 8;
4584
4585 //Why is this here??? Why is it needed???
4586 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4587
4588
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4589 {
4590 case 8:
4591 case up:
4592
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4593 return false;
4594
4595 69 dy = dy1-s;
4596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4598 69 break;
4599
4600 case 12:
4601 case down:
4602
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4603 return false;
4604
4605 51 dy = dy2+s;
4606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4607 51 break;
4608
4609 case 14:
4610 case left:
4611 47 dx = dx1-s;
4612 47 sv = ((isSideViewGravity())?7:8);
4613
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4614
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4615 47 break;
4616
4617 case 10:
4618 case right:
4619 85 dx = dx2+s;
4620 85 sv = ((isSideViewGravity())?7:8);
4621
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4622 85 break;
4623
4624 case 9:
4625 case r_up:
4626 94 dx = dx2+s;
4627 94 dy = dy1-s;
4628
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4630 94 break;
4631
4632 case 11:
4633 case r_down:
4634 78 dx = dx2+s;
4635 78 dx = dy2+s;
4636
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4638 78 break;
4639
4640 case 13:
4641 case l_down:
4642 57 dx = dx1-s;
4643 57 dy = dy2+s;
4644
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4646 57 break;
4647
4648 case 15:
4649 case l_up:
4650 81 dx = dx1-s;
4651 81 dy = dy1-s;
4652
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4654 81 break;
4655
4656 default:
4657 db=99;
4658 return true;
4659 }
4660
4661 562 return ok;
4662 562 }
4663
4664
4665
4666
4667 // returns true if next step is ok, false if there is something there
4668 7325285 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4669 {
4670 7325285 bool ok = false; //initialise the var, son't just declare it
4671 7325285 int32_t dx = 0, dy = 0;
4672 7325285 int32_t sv = 8;
4673 7325285 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4674 //Why is this here??? Why is it needed???
4675 7325285 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7325285 times.
7325285 int32_t usexoffs = (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7325285 times.
7325285 int32_t useyoffs = (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4678
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7325272 times.
7325285 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
4679
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7325272 times.
7325285 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4680 7325285 bool offgrid = OFFGRID_ENEMY;
4681
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7317994 times.
7325285 if(!offgrid)
4682 {
4683 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4684
1/2
✓ Branch 0 taken 7317994 times.
✗ Branch 1 not taken.
7317994 if(usehei<16)usehei=16;
4685
1/2
✓ Branch 0 taken 7317994 times.
✗ Branch 1 not taken.
7317994 if(usewid<16)usewid=16;
4686 7317994 }
4687
9/9
✓ Branch 0 taken 1327891 times.
✓ Branch 1 taken 1102926 times.
✓ Branch 2 taken 1222014 times.
✓ Branch 3 taken 1212951 times.
✓ Branch 4 taken 536645 times.
✓ Branch 5 taken 638123 times.
✓ Branch 6 taken 600184 times.
✓ Branch 7 taken 564898 times.
✓ Branch 8 taken 119653 times.
7325285 switch(ndir) //need to check every 8 pixels between two points
4688 {
4689 case 8:
4690 case up:
4691 {
4692
4/4
✓ Branch 0 taken 150637 times.
✓ Branch 1 taken 1177254 times.
✓ Branch 2 taken 150047 times.
✓ Branch 3 taken 590 times.
1327891 if(enemycanfall(id) && isSideViewGravity())
4693 590 return false;
4694
4695 1327301 dy = dy1-s;
4696
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1326821 times.
1327301 special = (special==spw_clipbottomright)?spw_none:special;
4697 1327301 tries = usewid/(offgrid ? 8 : 16);
4698 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4699
2/2
✓ Branch 0 taken 1127193 times.
✓ Branch 1 taken 1327951 times.
2455144 for ( ; tries > 0; --tries )
4700 {
4701
2/2
✓ Branch 0 taken 197488 times.
✓ Branch 1 taken 1130463 times.
1327951 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4702 1327951 try_x += (offgrid ? 8 : 16);
4703
2/2
✓ Branch 0 taken 1127843 times.
✓ Branch 1 taken 200108 times.
1327951 if (!ok) break;
4704 1127843 }
4705
2/2
✓ Branch 0 taken 1127193 times.
✓ Branch 1 taken 200108 times.
1327301 if(!ok) break;
4706
1/2
✓ Branch 0 taken 1127193 times.
✗ Branch 1 not taken.
1127193 if((usewid%16)>0) //Uneven width
4707 {
4708 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4709 }
4710 1127193 break;
4711 }
4712 case 12:
4713 case down:
4714 {
4715
4/4
✓ Branch 0 taken 180556 times.
✓ Branch 1 taken 922370 times.
✓ Branch 2 taken 179868 times.
✓ Branch 3 taken 688 times.
1102926 if(enemycanfall(id) && isSideViewGravity())
4716 688 return false;
4717
4718 1102238 dy = dy2+s;
4719 1102238 tries = usewid/(offgrid ? 8 : 16);
4720 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4721
2/2
✓ Branch 0 taken 896247 times.
✓ Branch 1 taken 1103022 times.
1999269 for ( ; tries > 0; --tries )
4722 {
4723
3/4
✓ Branch 0 taken 205243 times.
✓ Branch 1 taken 897779 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 897779 times.
1103022 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4724 1103022 try_x += (offgrid ? 8 : 16);
4725
2/2
✓ Branch 0 taken 897031 times.
✓ Branch 1 taken 205991 times.
1103022 if (!ok) break;
4726 897031 }
4727
2/2
✓ Branch 0 taken 896247 times.
✓ Branch 1 taken 205991 times.
1102238 if(!ok) break;
4728
1/2
✓ Branch 0 taken 896247 times.
✗ Branch 1 not taken.
896247 if((usewid%16)>0) //Uneven width
4729 {
4730 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4731 }
4732 896247 break;
4733 }
4734 case 14:
4735 case left:
4736 {
4737 1222014 dx = dx1-s;
4738 1222014 sv = ((isSideViewGravity())?7:0);
4739
4/4
✓ Branch 0 taken 1221391 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1219623 times.
1222014 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4740 1222014 tries = usehei/(offgrid ? 8 : 16);
4741 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4742
2/2
✓ Branch 0 taken 1023089 times.
✓ Branch 1 taken 1222931 times.
2246020 for ( ; tries > 0; --tries )
4743 {
4744
2/2
✓ Branch 0 taken 197742 times.
✓ Branch 1 taken 1025189 times.
1222931 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4745 1222931 try_y += (offgrid ? 8 : 16);
4746
2/2
✓ Branch 0 taken 1024006 times.
✓ Branch 1 taken 198925 times.
1222931 if (!ok) break;
4747 1024006 }
4748
2/2
✓ Branch 0 taken 1023089 times.
✓ Branch 1 taken 198925 times.
1222014 if(!ok) break;
4749
1/2
✓ Branch 0 taken 1023089 times.
✗ Branch 1 not taken.
1023089 if((usehei%16)>0) //Uneven height
4750 {
4751 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4752 }
4753 1023089 break;
4754 }
4755 case 10:
4756 case right:
4757 {
4758 1212951 dx = dx2+s;
4759 1212951 sv = ((isSideViewGravity())?7:0);
4760 1212951 tries = usehei/(offgrid ? 8 : 16);
4761 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4762
2/2
✓ Branch 0 taken 1024852 times.
✓ Branch 1 taken 1213845 times.
2238697 for ( ; tries > 0; --tries )
4763 {
4764
3/4
✓ Branch 0 taken 186746 times.
✓ Branch 1 taken 1027099 times.
✓ Branch 2 taken 1027099 times.
✗ Branch 3 not taken.
1213845 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4765 1213845 try_y += (offgrid ? 8 : 16);
4766
2/2
✓ Branch 0 taken 1025746 times.
✓ Branch 1 taken 188099 times.
1213845 if (!ok) break;
4767 1025746 }
4768
2/2
✓ Branch 0 taken 1024852 times.
✓ Branch 1 taken 188099 times.
1212951 if(!ok) break;
4769
1/2
✓ Branch 0 taken 1024852 times.
✗ Branch 1 not taken.
1024852 if((usehei%16)>0) //Uneven height
4770 {
4771 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4772 }
4773 1024852 break;
4774 }
4775 case 9:
4776 case r_up:
4777 {
4778 536645 dx = dx2+s;
4779 536645 dy = dy1-s;
4780 536645 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4781 536645 sv = ((isSideViewGravity())?7:0);
4782
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 536645 times.
1056288 for ( ; tries_x > 0; --tries_x )
4783 {
4784 536645 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4785 536645 try_y = 0;
4786
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 536645 times.
1056288 for ( ; tries_y > 0; --tries_y )
4787 {
4788
4/4
✓ Branch 0 taken 528401 times.
✓ Branch 1 taken 8244 times.
✓ Branch 2 taken 522980 times.
✓ Branch 3 taken 5421 times.
1059625 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4789
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 520588 times.
522980 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4790 536645 try_y += (offgrid ? 8 : 16);
4791
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if (!ok) break;
4792 519643 }
4793
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if (!ok) break;
4794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 519643 times.
519643 if((usehei%16)>0) //Uneven height
4795 {
4796 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4797 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4798 }
4799 519643 try_x += (offgrid ? 8 : 16);
4800 519643 }
4801
2/2
✓ Branch 0 taken 519643 times.
✓ Branch 1 taken 17002 times.
536645 if(!ok) break;
4802
1/2
✓ Branch 0 taken 519643 times.
✗ Branch 1 not taken.
519643 if((usewid%16)>0) //Uneven width
4803 {
4804 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4805 try_y = 0;
4806 for ( ; tries_y > 0; --tries_y )
4807 {
4808 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4809 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4810 try_y += (offgrid ? 8 : 16);
4811 if (!ok) break;
4812 }
4813 if (!ok) break;
4814 if((usehei%16)>0) //Uneven height
4815 {
4816 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4817 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4818 }
4819 }
4820 519643 break;
4821 }
4822 case 11:
4823 case r_down:
4824 {
4825 638123 dx = dx2+s;
4826 638123 dx = dy2+s;
4827 638123 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4828 //sv = ((isSideViewGravity())?7:0);
4829
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 638123 times.
1260896 for ( ; tries_x > 0; --tries_x )
4830 {
4831 638123 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4832 638123 try_y = 0;
4833
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 638123 times.
1260896 for ( ; tries_y > 0; --tries_y )
4834 {
4835
4/4
✓ Branch 0 taken 636612 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 623840 times.
✓ Branch 3 taken 12772 times.
1261963 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4836
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 623734 times.
623840 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4837 638123 try_y += (offgrid ? 8 : 16);
4838
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if (!ok) break;
4839 622773 }
4840
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if (!ok) break;
4841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 622773 times.
622773 if((usehei%16)>0) //Uneven height
4842 {
4843 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4844 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4845 }
4846 622773 try_x += (offgrid ? 8 : 16);
4847 622773 }
4848
2/2
✓ Branch 0 taken 622773 times.
✓ Branch 1 taken 15350 times.
638123 if(!ok) break;
4849
1/2
✓ Branch 0 taken 622773 times.
✗ Branch 1 not taken.
622773 if((usewid%16)>0) //Uneven width
4850 {
4851 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4852 try_y = 0;
4853 for ( ; tries_y > 0; --tries_y )
4854 {
4855 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4856 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4857 try_y += (offgrid ? 8 : 16);
4858 if (!ok) break;
4859 }
4860 if (!ok) break;
4861 if((usehei%16)>0) //Uneven height
4862 {
4863 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4864 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4865 }
4866 }
4867 622773 break;
4868 }
4869 case 13:
4870 case l_down:
4871 {
4872 600184 dx = dx1-s;
4873 600184 dy = dy2+s;
4874 600184 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4875 //sv = ((isSideViewGravity())?7:0);
4876
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 600184 times.
1183330 for ( ; tries_x > 0; --tries_x )
4877 {
4878 600184 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4879 600184 try_y = 0;
4880
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 600184 times.
1183330 for ( ; tries_y > 0; --tries_y )
4881 {
4882
4/4
✓ Branch 0 taken 588277 times.
✓ Branch 1 taken 11907 times.
✓ Branch 2 taken 584012 times.
✓ Branch 3 taken 4265 times.
1184196 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4883
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 583444 times.
584012 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4884 600184 try_y += (offgrid ? 8 : 16);
4885
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if (!ok) break;
4886 583146 }
4887
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if (!ok) break;
4888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 583146 times.
583146 if((usehei%16)>0) //Uneven height
4889 {
4890 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4891 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4892 }
4893 583146 try_x += (offgrid ? 8 : 16);
4894 583146 }
4895
2/2
✓ Branch 0 taken 583146 times.
✓ Branch 1 taken 17038 times.
600184 if(!ok) break;
4896
1/2
✓ Branch 0 taken 583146 times.
✗ Branch 1 not taken.
583146 if((usewid%16)>0) //Uneven width
4897 {
4898 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4899 try_y = 0;
4900 for ( ; tries_y > 0; --tries_y )
4901 {
4902 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4903 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4904 try_y += (offgrid ? 8 : 16);
4905 if (!ok) break;
4906 }
4907 if (!ok) break;
4908 if((usehei%16)>0) //Uneven height
4909 {
4910 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4911 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4912 }
4913 }
4914 583146 break;
4915 }
4916 case 15:
4917 case l_up:
4918 {
4919 564898 dx = dx1-s;
4920 564898 dy = dy1-s;
4921 564898 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4922 564898 sv = ((isSideViewGravity())?7:0);
4923
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 564898 times.
1113902 for ( ; tries_x > 0; --tries_x )
4924 {
4925 564898 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4926 564898 try_y = 0;
4927
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 564898 times.
1113902 for ( ; tries_y > 0; --tries_y )
4928 {
4929
4/4
✓ Branch 0 taken 556265 times.
✓ Branch 1 taken 8633 times.
✓ Branch 2 taken 552308 times.
✓ Branch 3 taken 3957 times.
1117206 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4930
2/2
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 549869 times.
552308 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4931 564898 try_y += (offgrid ? 8 : 16);
4932
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if (!ok) break;
4933 549004 }
4934
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if (!ok) break;
4935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 549004 times.
549004 if((usehei%16)>0) //Uneven height
4936 {
4937 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4938 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4939 }
4940 549004 try_x += (offgrid ? 8 : 16);
4941 549004 }
4942
2/2
✓ Branch 0 taken 549004 times.
✓ Branch 1 taken 15894 times.
564898 if(!ok) break;
4943
1/2
✓ Branch 0 taken 549004 times.
✗ Branch 1 not taken.
549004 if((usewid%16)>0) //Uneven width
4944 {
4945 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4946 try_y = 0;
4947 for ( ; tries_y > 0; --tries_y )
4948 {
4949 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4950 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4951 try_y += (offgrid ? 8 : 16);
4952 if (!ok) break;
4953 }
4954 if (!ok) break;
4955 if((usehei%16)>0) //Uneven height
4956 {
4957 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4958 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4959 }
4960 }
4961 549004 break;
4962 }
4963 default:
4964 119653 db=99;
4965 119653 return true;
4966 }
4967 //Z_eventlog("\n");
4968 7204354 return ok;
4969 7325285 }
4970
4971
4972 4624298 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4973 {
4974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4624298 times.
4624298 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
4975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4624298 times.
4624298 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4976
1/2
✓ Branch 0 taken 4624298 times.
✗ Branch 1 not taken.
4624298 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4977
1/2
✓ Branch 0 taken 4624298 times.
✗ Branch 1 not taken.
4624298 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4978 4624298 --usewid;
4979 4624298 --usehei;
4980 4624298 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4981 }
4982
4983 1243207 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
4984 {
4985 1243207 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
4986
4987
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1236388 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1243207 if(special==spw_clipright&&ndir==right)
4988 {
4989 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
4990 1798 }
4991
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1243202 times.
1243207 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
4992
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1243202 times.
1243207 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4993
1/2
✓ Branch 0 taken 1243207 times.
✗ Branch 1 not taken.
1243207 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4994
1/2
✓ Branch 0 taken 1243207 times.
✗ Branch 1 not taken.
1243207 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4995 1243207 --usewid;
4996 1243207 --usehei;
4997
2/2
✓ Branch 0 taken 716881 times.
✓ Branch 1 taken 526326 times.
1243207 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
4998 }
4999
5000 136202 bool enemy::canmove(int32_t ndir, bool kb)
5001 {
5002 136202 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5003 }
5004
5005 // 8-directional
5006 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5007 {
5008 562 int32_t ndir=0;
5009
5010 // can move straight, check if it wants to turn
5011
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5012 {
5013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5014 {
5015 int32_t w = Lwpns.idFirst(wBait);
5016
5017 if(w>=0)
5018 {
5019 int32_t bx = Lwpns.spr(w)->x;
5020 int32_t by = Lwpns.spr(w)->y;
5021
5022 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5023
5024 if(abs(int32_t(y)-by)>14)
5025 {
5026 if(ndir>0) // Already left or right
5027 {
5028 // Making the diagonal directions
5029 ndir += (by<y) ? 2 : 4;
5030 }
5031 else
5032 {
5033 ndir = (by<y) ? up : down;
5034 }
5035 }
5036
5037 if(canmove(ndir,special,false))
5038 {
5039 dir=ndir;
5040 return;
5041 }
5042 }
5043 }
5044
5045 // Homing added.
5046
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5047 {
5048 ndir = lined_up(8,true);
5049
5050 if(ndir>=0 && canmove(ndir,special,false))
5051 {
5052 dir=ndir;
5053 }
5054
5055 return;
5056 }
5057
5058 549 int32_t r=zc_oldrand();
5059
5060
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5061 {
5062 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5063 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5064
5065
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5066 525 dir=ndir;
5067
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5068 19 dir=ndir2;
5069
5070
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5071 // due to numerous lost fractional components. -L
5072 {
5073 x.doFloor();
5074 y.doFloor();
5075 }
5076 549 }
5077
5078 549 return;
5079 }
5080
5081 // can't move straight, must turn
5082 13 int32_t i=0;
5083
5084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5085 {
5086 20 ndir=(zc_oldrand()&7)+8;
5087
5088
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5089 13 break;
5090 7 }
5091
5092
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5093 {
5094 for(ndir=8; ndir<16; ndir++)
5095 {
5096 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5097 goto ok;
5098 }
5099
5100 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5101 }
5102
5103 ok:
5104 13 dir=ndir;
5105 13 x.doFloor();
5106 13 y.doFloor();
5107 562 }
5108
5109 577113 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5110 {
5111 577113 int32_t ndir=0;
5112
5113 // can move straight, check if it wants to turn
5114
2/2
✓ Branch 0 taken 544558 times.
✓ Branch 1 taken 32555 times.
577113 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5115 {
5116
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 544351 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
544558 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5117 {
5118 101 int32_t i = Lwpns.idFirst(wBait);
5119
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5120 {
5121 weapon *w = (weapon*)Lwpns.spr(i);
5122 if (get_qr(qr_FIND_CLOSEST_BAIT))
5123 {
5124 int32_t currentrange;
5125 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5126 else currentrange = -1;
5127 int curid = i;
5128 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5129 for(; i<Lwpns.Count(); ++i)
5130 {
5131 weapon *lw = (weapon*)Lwpns.spr(i);
5132 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5133 {
5134 currentrange = distance(x, y, lw->x, lw->y);
5135 curid = i;
5136 }
5137 }
5138 i = curid;
5139 if (currentrange == -1) i = -1;
5140 }
5141 else
5142 {
5143 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5144 }
5145 if(i>=0)
5146 {
5147 int32_t bx = Lwpns.spr(i)->x;
5148 int32_t by = Lwpns.spr(i)->y;
5149
5150 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5151
5152 if(abs(int32_t(y)-by)>14)
5153 {
5154 if(ndir>0) // Already left or right
5155 {
5156 // Making the diagonal directions
5157 ndir += (by<y) ? 2 : 4;
5158 }
5159 else
5160 {
5161 ndir = (by<y) ? up : down;
5162 }
5163 }
5164 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5165 if(canmove(ndir,special,false))
5166 {
5167 dir=ndir;
5168 return;
5169 }
5170 }
5171 }
5172 101 }
5173
5174 // Homing added.
5175
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 514932 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
544558 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5176 {
5177 14216 ndir = lined_up(8,true);
5178
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5179
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5180 {
5181 5852 dir=ndir;
5182 5852 }
5183
5184 14216 return;
5185 }
5186
5187 530342 int32_t r=zc_oldrand();
5188
5189
4/4
✓ Branch 0 taken 338430 times.
✓ Branch 1 taken 191912 times.
✓ Branch 2 taken 178921 times.
✓ Branch 3 taken 159509 times.
530342 if(newrate>0 && !(r%newrate))
5190 {
5191 159509 ndir = ((dir+((r&64)?-1:1))&7)+8;
5192 159509 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5193
5194
2/2
✓ Branch 0 taken 153722 times.
✓ Branch 1 taken 5787 times.
159509 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5195 153722 dir=ndir;
5196
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4930 times.
5787 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5197 4930 dir=ndir2;
5198
5199
4/4
✓ Branch 0 taken 153722 times.
✓ Branch 1 taken 5787 times.
✓ Branch 2 taken 146396 times.
✓ Branch 3 taken 7326 times.
159509 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5200 // due to numerous lost fractional components. -L
5201 {
5202 7326 x.doFloor();
5203 7326 y.doFloor();
5204 7326 }
5205 159509 }
5206
5207 530342 return;
5208 }
5209
5210 // can't move straight, must turn
5211 32555 int32_t i=0;
5212
5213
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 60993 times.
61063 for(; i<32; i++) // Try random dir
5214 {
5215 60993 ndir=(zc_oldrand()&7)+8;
5216
5217
2/2
✓ Branch 0 taken 28508 times.
✓ Branch 1 taken 32485 times.
60993 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5218 32485 break;
5219 28508 }
5220
5221
2/2
✓ Branch 0 taken 32485 times.
✓ Branch 1 taken 70 times.
32608 if(i==32)
5222 {
5223
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 53 times.
514 for(ndir=8; ndir<16; ndir++)
5224 {
5225
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 17 times.
461 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5226 17 goto ok;
5227 444 }
5228
5229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5230 53 }
5231
5232 ok:
5233 32555 dir=ndir;
5234 32555 x.doFloor();
5235 32555 y.doFloor();
5236 577113 }
5237
5238 570638 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5239 {
5240 570638 newdir_8(newrate,newhoming,special,0,-8,15,15);
5241 570638 }
5242
5243 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5244 {
5245 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5246 562 }
5247
5248 // makes the enemy slide backwards when hit
5249 // sclk: first byte is clk, second byte is dir
5250 // makes the enemy slide backwards when hit
5251 // sclk: first byte is clk, second byte is dir
5252 15625251 int32_t enemy::slide()
5253 {
5254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15625251 times.
15625251 if(script_knockback_clk!=0) //scripted knockback
5255 {
5256 sclk = 0;
5257 return 1; //scripted knockback ran
5258 }
5259
5/6
✓ Branch 0 taken 102102 times.
✓ Branch 1 taken 15523149 times.
✓ Branch 2 taken 7848 times.
✓ Branch 3 taken 94254 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7848 times.
15625251 if(sclk==0 || (hp<=0 && !immortal))
5260 15530997 return 0;
5261
5262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94254 times.
94254 if(knockbackflags & FLAG_NOSLIDE)
5263 {
5264 sclk = 0;
5265 if(!OFFGRID_ENEMY)
5266 {
5267 //Fix to grid
5268 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
5269 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
5270 do_fix(x, 16, true);
5271 do_fix(y, 16, true);
5272 }
5273 return 0;
5274 }
5275
8/10
✓ Branch 0 taken 9554 times.
✓ Branch 1 taken 84700 times.
✓ Branch 2 taken 296 times.
✓ Branch 3 taken 9258 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 296 times.
✓ Branch 6 taken 7105 times.
✓ Branch 7 taken 2153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 296 times.
94254 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5276 {
5277 2153 sclk=0;
5278 2153 return 0;
5279 }
5280
5281 92101 --sclk;
5282
5283
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10539 times.
✓ Branch 2 taken 12291 times.
✓ Branch 3 taken 31734 times.
✓ Branch 4 taken 35752 times.
92101 switch(sclk>>8)
5284 {
5285 case up:
5286 {
5287
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9449 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10532 times.
10539 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5288 {
5289 7 sclk=0;
5290 7 return 0;
5291 }
5292
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9442 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10532 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5293
5294 10357 break;
5295 }
5296 case down:
5297 {
5298
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12289 times.
12291 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5299 {
5300 2 sclk=0;
5301 2 return 0;
5302 }
5303
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11220 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12289 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5304
5305 12143 break;
5306 }
5307 case left:
5308 {
5309
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29380 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31721 times.
31734 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5310 {
5311 13 sclk=0;
5312 13 return 0;
5313 }
5314
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29367 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31721 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5315
5316 31483 break;
5317 }
5318 case right:
5319 {
5320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35752 times.
35752 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5321 {
5322 sclk=0;
5323 return 0;
5324 }
5325
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32464 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35752 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5326 35482 break;
5327 }
5328 }
5329
5330 91250 int32_t move = knockbackSpeed;
5331
2/2
✓ Branch 0 taken 86366 times.
✓ Branch 1 taken 91250 times.
177616 while(move>0)
5332 {
5333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91250 times.
91250 int32_t thismove = zc_min(8, move);
5334 91250 move -= thismove;
5335 91250 hitdir = (sclk>>8);
5336
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10357 times.
✓ Branch 2 taken 12143 times.
✓ Branch 3 taken 31483 times.
✓ Branch 4 taken 35482 times.
91250 switch(sclk>>8)
5337 {
5338 case up:
5339 10357 y-=thismove;
5340 10357 break;
5341
5342 case down:
5343 12143 y+=thismove;
5344 12143 break;
5345
5346 case left:
5347 31483 x-=thismove;
5348 31483 break;
5349
5350 case right:
5351 35482 x+=thismove;
5352 35482 break;
5353 }
5354
2/2
✓ Branch 0 taken 86366 times.
✓ Branch 1 taken 4884 times.
91250 if(!canmove(sclk>>8,(zfix)0,0,true))
5355 {
5356
3/3
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 2907 times.
✓ Branch 2 taken 4 times.
4884 switch(sclk>>8)
5357 {
5358 case up:
5359 case down:
5360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1973 times.
1973 if(y < 0)
5361 y = 0;
5362
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1648 times.
1973 else if((int32_t(y)&15) > 7)
5363 325 y=(int32_t(y)&0xF0)+16;
5364 else
5365 1648 y=(int32_t(y)&0xF0);
5366
5367 1973 break;
5368
5369 case left:
5370 case right:
5371
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2903 times.
2907 if(x < 0)
5372 4 x = 0;
5373
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 2070 times.
2903 else if((int32_t(x)&15) > 7)
5374 833 x=(int32_t(x)&0xF0)+16;
5375 else
5376 2070 x=(int32_t(x)&0xF0);
5377
5378 2907 break;
5379 }
5380
5381 4884 sclk=0;
5382 4884 clk3=0;
5383 4884 break;
5384 }
5385 }
5386
5387
2/2
✓ Branch 0 taken 83887 times.
✓ Branch 1 taken 7363 times.
91250 if((sclk&255)==0)
5388 {
5389 //hitdir = -1;
5390 7363 sclk=0;
5391 7363 }
5392 91250 return 2;
5393 15625251 }
5394
5395 bool enemy::can_slide()
5396 {
5397 if(sclk==0 || (hp<=0 && !immortal))
5398 return false;
5399
5400 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5401 {
5402 return false;
5403 }
5404
5405 return true;
5406 }
5407
5408 bool enemy::fslide()
5409 {
5410 if(sclk==0 || (hp<=0 && !immortal))
5411 return false;
5412
5413 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5414 {
5415 sclk=0;
5416 return false;
5417 }
5418
5419 --sclk;
5420
5421 switch(sclk>>8)
5422 {
5423 case up:
5424 if(y<=16)
5425 {
5426 sclk=0;
5427 return false;
5428 }
5429
5430 break;
5431
5432 case down:
5433 if(y>=160)
5434 {
5435 sclk=0;
5436 return false;
5437 }
5438
5439 break;
5440
5441 case left:
5442 if(x<=16)
5443 {
5444 sclk=0;
5445 return false;
5446 }
5447
5448 break;
5449
5450 case right:
5451 if(x>=240)
5452 {
5453 sclk=0;
5454 return false;
5455 }
5456
5457 break;
5458 }
5459 hitdir = (sclk>>8);
5460 switch(sclk>>8)
5461 {
5462 case up:
5463 y-=4;
5464 break;
5465
5466 case down:
5467 y+=4;
5468 break;
5469
5470 case left:
5471 x-=4;
5472 break;
5473
5474 case right:
5475 x+=4;
5476 break;
5477 }
5478
5479 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5480 {
5481 switch(sclk>>8)
5482 {
5483 case up:
5484 case down:
5485 if((int32_t(y)&15) > 7)
5486 y=(int32_t(y)&0xF0)+16;
5487 else
5488 y=(int32_t(y)&0xF0);
5489
5490 break;
5491
5492 case left:
5493 case right:
5494 if((int32_t(x)&15) > 7)
5495 x=(int32_t(x)&0xF0)+16;
5496 else
5497 x=(int32_t(x)&0xF0);
5498
5499 break;
5500 }
5501
5502 sclk=0;
5503 clk3=0;
5504 }
5505
5506 if((sclk&255)==0)
5507 sclk=0;
5508
5509 return true;
5510 }
5511
5512 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5513 {
5514 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5515 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5516 bool ret = sprite::knockback(time, dir, speed);
5517 if(ret) sclk = 0; //kill engine knockback if interrupted
5518 //! Perhaps also set hitdir here, if needed for timing? -Z
5519 return ret;
5520 }
5521
5522 37824259 bool enemy::runKnockback()
5523 {
5524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37824259 times.
37824259 if((script_knockback_clk&0xFF)==0)
5525 {
5526 37824259 script_knockback_clk = 0;
5527 37824259 return false;
5528 }
5529 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5530 {
5531 return false;
5532 }
5533 int32_t move = script_knockback_speed;
5534 int32_t kb_dir = script_knockback_clk>>8;
5535 --script_knockback_clk;
5536
5537 while(move>0)
5538 {
5539 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5540 move -= thismove;
5541 hitdir = kb_dir;
5542 switch(kb_dir)
5543 {
5544 case r_up:
5545 case l_up:
5546 case up:
5547 y-=thismove;
5548 break;
5549
5550 case r_down:
5551 case l_down:
5552 case down:
5553 y+=thismove;
5554 break;
5555 }
5556 switch(kb_dir)
5557 {
5558 case l_up:
5559 case l_down:
5560 case left:
5561 x-=thismove;
5562 break;
5563
5564 case r_up:
5565 case r_down:
5566 case right:
5567 x+=thismove;
5568 break;
5569 }
5570 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5571 {
5572 if(!canmove(kb_dir,(zfix)0,0,true))
5573 {
5574 script_knockback_clk=0;
5575 clk3=0;
5576 //Fix to grid
5577 switch(kb_dir)
5578 {
5579 case up:
5580 case down:
5581 break;
5582 default:
5583 if(x < 0)
5584 x = 0;
5585 else if((int32_t(x)&15) > 7)
5586 x=(int32_t(x)&0xF0)+16;
5587 else
5588 x=(int32_t(x)&0xF0);
5589 break;
5590 }
5591 switch(kb_dir)
5592 {
5593 case left:
5594 case right:
5595 break;
5596 default:
5597 if(y < 0)
5598 y = 0;
5599 else if((int32_t(y)&15) > 7)
5600 y=(int32_t(y)&0xF0)+16;
5601 else
5602 y=(int32_t(y)&0xF0);
5603 break;
5604 }
5605 break;
5606 }
5607 }
5608 else
5609 {
5610 if(!scr_canplace(x,y,0,true))
5611 {
5612 script_knockback_clk=0;
5613 clk3=0;
5614 //Fix to grid
5615 if (OFFGRID_ENEMY)
5616 {
5617 switch(kb_dir)
5618 {
5619 case up:
5620 case down:
5621 break;
5622 default:
5623 if(x < 0)
5624 x = 0;
5625 else if((int32_t(x)&7) > 3)
5626 x=(int32_t(x)&0xF8)+8;
5627 else
5628 x=(int32_t(x)&0xF8);
5629 break;
5630 }
5631 switch(kb_dir)
5632 {
5633 case left:
5634 case right:
5635 break;
5636 default:
5637 if(y < 0)
5638 y = 0;
5639 else if((int32_t(y)&7) > 3)
5640 y=(int32_t(y)&0xF8)+8;
5641 else
5642 y=(int32_t(y)&0xF8);
5643 break;
5644 }
5645 }
5646 else
5647 {
5648 switch(kb_dir)
5649 {
5650 case up:
5651 case down:
5652 break;
5653 default:
5654 if(x < 0)
5655 x = 0;
5656 else if((int32_t(x)&15) > 7)
5657 x=(int32_t(x)&0xF0)+16;
5658 else
5659 x=(int32_t(x)&0xF0);
5660 break;
5661 }
5662 switch(kb_dir)
5663 {
5664 case left:
5665 case right:
5666 break;
5667 default:
5668 if(y < 0)
5669 y = 0;
5670 else if((int32_t(y)&15) > 7)
5671 y=(int32_t(y)&0xF0)+16;
5672 else
5673 y=(int32_t(y)&0xF0);
5674 break;
5675 }
5676 }
5677 break;
5678 }
5679
5680 }
5681 }
5682 return true;
5683 37824259 }
5684 // changes enemy's direction, checking restrictions
5685 // rate: 0 = no random changes, 16 = always random change
5686 // homing: 0 = none, 256 = always
5687 // grumble 0 = none, 4 = strongest appetite
5688 520367 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5689 {
5690 520367 int32_t ndir=-1;
5691
5692
4/4
✓ Branch 0 taken 109954 times.
✓ Branch 1 taken 410413 times.
✓ Branch 2 taken 37802 times.
✓ Branch 3 taken 72152 times.
520367 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
5693 {
5694 72152 int32_t i = Lwpns.idFirst(wBait);
5695
1/2
✓ Branch 0 taken 72152 times.
✗ Branch 1 not taken.
72152 if(i >= 0) //idfirst returns -1 if it can't find any
5696 {
5697 weapon *w = (weapon*)Lwpns.spr(i);
5698 if (get_qr(qr_FIND_CLOSEST_BAIT))
5699 {
5700 int32_t currentrange;
5701 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5702 else currentrange = -1;
5703 int curid = i;
5704 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5705 for(; i<Lwpns.Count(); ++i)
5706 {
5707 weapon *lw = (weapon*)Lwpns.spr(i);
5708 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5709 {
5710 currentrange = distance(x, y, lw->x, lw->y);
5711 curid = i;
5712 }
5713 }
5714 i = curid;
5715 if (currentrange == -1) i = -1;
5716 }
5717 else
5718 {
5719 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5720 }
5721 if (i >= 0)
5722 {
5723 int32_t bx = Lwpns.spr(i)->x;
5724 int32_t by = Lwpns.spr(i)->y;
5725
5726 if(abs(int32_t(y)-by)>14)
5727 {
5728 ndir = (by<y) ? up : down;
5729 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5730 if(canmove(ndir,special,false))
5731 {
5732 dir=ndir;
5733 return;
5734 }
5735 }
5736
5737 ndir = (bx<x) ? left : right;
5738 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5739 if(canmove(ndir,special,false))
5740 {
5741 dir=ndir;
5742 return;
5743 }
5744 }
5745 }
5746 72152 }
5747
5748
2/2
✓ Branch 0 taken 352478 times.
✓ Branch 1 taken 167889 times.
520367 if((zc_oldrand()&255)<abs(newhoming))
5749 {
5750 167889 ndir = lined_up(8,false);
5751
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167889 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167889 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5752
4/4
✓ Branch 0 taken 45334 times.
✓ Branch 1 taken 122555 times.
✓ Branch 2 taken 5715 times.
✓ Branch 3 taken 39619 times.
167889 if(ndir>=0 && canmove(ndir,special,false))
5753 {
5754 39619 dir=ndir;
5755 39619 return;
5756 }
5757 128270 }
5758
5759 480748 int32_t i=0;
5760
5761
2/2
✓ Branch 0 taken 3335 times.
✓ Branch 1 taken 1179509 times.
1182844 for(; i<32; i++)
5762 {
5763 1179509 int32_t r=zc_oldrand();
5764
5765
2/2
✓ Branch 0 taken 344692 times.
✓ Branch 1 taken 834817 times.
1179509 if((r&15)<newrate)
5766 344692 ndir=(r>>4)&3;
5767 else
5768 834817 ndir=dir;
5769
5770
2/2
✓ Branch 0 taken 702096 times.
✓ Branch 1 taken 477413 times.
1179509 if(canmove(ndir,special,false))
5771 477413 break;
5772 702096 }
5773
5774
2/2
✓ Branch 0 taken 477413 times.
✓ Branch 1 taken 3335 times.
481501 if(i==32)
5775 {
5776
2/2
✓ Branch 0 taken 8919 times.
✓ Branch 1 taken 753 times.
9672 for(ndir=0; ndir<4; ndir++)
5777 {
5778
2/2
✓ Branch 0 taken 6337 times.
✓ Branch 1 taken 2582 times.
8919 if(canmove(ndir,special,false))
5779 2582 goto ok;
5780 6337 }
5781
5782
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 693 times.
753 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5783 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5784 753 }
5785
5786 ok:
5787 480748 dir = ndir;
5788 520367 }
5789
5790 2633 void enemy::newdir()
5791 {
5792 2633 newdir(4,0,spw_none);
5793 2633 }
5794
5795 zfix enemy::distance_left()
5796 {
5797 int32_t a2=x.getInt();
5798 int32_t b2=y.getInt();
5799
5800 switch(dir)
5801 {
5802 case up:
5803 return (zfix)(b2&0xF);
5804
5805 case down:
5806 return (zfix)(16-(b2&0xF));
5807
5808 case left:
5809 return (zfix)(a2&0xF);
5810
5811 case right:
5812 return (zfix)(16-(a2&0xF));
5813 }
5814
5815 return (zfix)0;
5816 }
5817
5818 // keeps walking around
5819 391434 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5820 {
5821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391434 times.
391434 if(slide())
5822 return;
5823
5824
8/12
✓ Branch 0 taken 387600 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 387600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 383173 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 383173 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 383173 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 383173 times.
391434 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5825 8261 return;
5826
5827
2/2
✓ Branch 0 taken 26115 times.
✓ Branch 1 taken 357058 times.
383173 if(clk3<=0)
5828 {
5829 26115 fix_coords(true);
5830 26115 newdir(newrate,newhoming,special);
5831
5832
1/2
✓ Branch 0 taken 26115 times.
✗ Branch 1 not taken.
26115 if(step==0)
5833 clk3=0;
5834 else
5835 26115 clk3=int32_t(16.0/step);
5836 26115 }
5837
2/2
✓ Branch 0 taken 357013 times.
✓ Branch 1 taken 45 times.
357058 else if(scored)
5838 {
5839 45 dir^=1;
5840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5841 else clk3=32767;
5842 45 }
5843
5844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383173 times.
383173 if (step != 0) --clk3;
5845 383173 move(step);
5846 391434 }
5847
5848 void enemy::constant_walk()
5849 {
5850 constant_walk(4,0,spw_none);
5851 }
5852
5853 35220 int32_t enemy::pos(int32_t newx,int32_t newy)
5854 {
5855 35220 return (newy<<8)+newx;
5856 }
5857
5858 // for variable step rates
5859 473814 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5860 {
5861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
473814 if(slide())
5862 return;
5863
5864
10/14
✓ Branch 0 taken 473814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 465189 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 455915 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 418370 times.
✓ Branch 9 taken 37545 times.
✓ Branch 10 taken 418370 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 418370 times.
✗ Branch 13 not taken.
473814 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5865 55444 return;
5866
5867 418370 zfix dx = (zfix)0;
5868 418370 zfix dy = (zfix)0;
5869
5870
5/9
✓ Branch 0 taken 93441 times.
✓ Branch 1 taken 97752 times.
✓ Branch 2 taken 111603 times.
✓ Branch 3 taken 113743 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
418370 switch(dir)
5871 {
5872 case 8:
5873 case up:
5874 93441 dy-=step;
5875 93441 break;
5876
5877 case 12:
5878 case down:
5879 97752 dy+=step;
5880 97752 break;
5881
5882 case 14:
5883 case left:
5884 111603 dx-=step;
5885 111603 break;
5886
5887 case 10:
5888 case right:
5889 113743 dx+=step;
5890 113743 break;
5891
5892 case 15:
5893 case l_up:
5894 dx-=step;
5895 dy-=step;
5896 break;
5897
5898 case 9:
5899 case r_up:
5900 dx+=step;
5901 dy-=step;
5902 break;
5903
5904 case 13:
5905 case l_down:
5906 dx-=step;
5907 dy+=step;
5908 break;
5909
5910 case 11:
5911 case r_down:
5912 dx+=step;
5913 dy+=step;
5914 break;
5915 }
5916
5917
8/8
✓ Branch 0 taken 204198 times.
✓ Branch 1 taken 214172 times.
✓ Branch 2 taken 22777 times.
✓ Branch 3 taken 181421 times.
✓ Branch 4 taken 11556 times.
✓ Branch 5 taken 11221 times.
✓ Branch 6 taken 405927 times.
✓ Branch 7 taken 12443 times.
418370 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5918 406814 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5919 {
5920 12443 fix_coords();
5921 12443 newdir(newrate,newhoming,special);
5922 12443 clk3=pos(x,y);
5923 12443 }
5924
5925 418370 move(step);
5926 473814 }
5927
5928 // pauses for a while after it makes a complete move (to a new square)
5929 12316472 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5930 {
5931
4/4
✓ Branch 0 taken 79889 times.
✓ Branch 1 taken 12236583 times.
✓ Branch 2 taken 67057 times.
✓ Branch 3 taken 12832 times.
12316472 if(sclk && clk2)
5932 {
5933 12832 clk3=0;
5934 12832 }
5935
5936
11/14
✓ Branch 0 taken 12243450 times.
✓ Branch 1 taken 73022 times.
✓ Branch 2 taken 12243450 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12243450 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11776236 times.
✓ Branch 7 taken 467214 times.
✓ Branch 8 taken 11638487 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11635279 times.
✓ Branch 11 taken 3208 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11635279 times.
12316472 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5937 {
5938 681193 return;
5939 }
5940
5941
2/2
✓ Branch 0 taken 2132459 times.
✓ Branch 1 taken 9502820 times.
11635279 if(clk2>0)
5942 {
5943 2132459 --clk2;
5944 2132459 return;
5945 }
5946
5947
2/2
✓ Branch 0 taken 410660 times.
✓ Branch 1 taken 9092160 times.
9502820 if(clk3<=0)
5948 {
5949 410660 fix_coords(true);
5950 410660 newdir(newrate,newhoming,special);
5951 410660 clk3=int32_t(16.0/step);
5952
2/2
✓ Branch 0 taken 410465 times.
✓ Branch 1 taken 195 times.
410660 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410660 times.
410660 if(clk2<0)
5954 {
5955 clk2=0;
5956 }
5957
2/2
✓ Branch 0 taken 54758 times.
✓ Branch 1 taken 355902 times.
410660 else if((zc_oldrand()&15)<newhrate)
5958 {
5959 54758 clk2=haltcnt;
5960 54758 return;
5961 }
5962 355902 }
5963
2/2
✓ Branch 0 taken 9089001 times.
✓ Branch 1 taken 3159 times.
9092160 else if(scored)
5964 {
5965 3159 dir^=1;
5966
5967
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3154 times.
3159 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5968 5 else clk3=32767;
5969 3159 }
5970
5971
2/2
✓ Branch 0 taken 74649 times.
✓ Branch 1 taken 9373413 times.
9448062 if (step != 0) --clk3;
5972 9448062 move(step);
5973 12316472 }
5974
5975 // 8-directional movement, aligns to 8 pixels
5976 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5977 {
5978 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5979 return;
5980
5981 if(clk3<=0)
5982 {
5983 newdir_8(newrate,newhoming,special);
5984 clk3=int32_t(8.0/step);
5985 if (step == 0) clk3 = 32767;
5986 }
5987
5988 if (step != 0) --clk3;
5989 move(step);
5990 }
5991 // 8-directional movement, aligns to 8 pixels
5992 242393 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5993 {
5994
6/12
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242393 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 242393 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 242393 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 242393 times.
242393 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5995 return;
5996
5997
2/2
✓ Branch 0 taken 226158 times.
✓ Branch 1 taken 16235 times.
242393 if(clk3<=0)
5998 {
5999 16235 newdir_8(newrate,newhoming,special);
6000 16235 clk3=int32_t(8.0/step);
6001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16235 times.
16235 if (step == 0) clk3 = 32767;
6002 16235 }
6003
6004
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if (step != 0) --clk3;
6005 242393 move(step);
6006 242393 }
6007
6008 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6009 {
6010 if(clk<0 || dying || stunclk || watch || frozenclock)
6011 return;
6012
6013 if(!canmove(dir,step,special,false))
6014 clk3=0;
6015
6016 if(clk2>0)
6017 {
6018 --clk2;
6019 return;
6020 }
6021
6022 if(clk3<=0)
6023 {
6024 newdir_8(newrate,newhoming,special);
6025 clk3=newclk;
6026
6027 if(clk2<0)
6028 {
6029 clk2=0;
6030 }
6031 else if((zc_oldrand()&15)<newhrate)
6032 {
6033 newdir_8(newrate,newhoming,special);
6034 clk2=haltcnt;
6035 return;
6036 }
6037 }
6038
6039 --clk3;
6040 move(step);
6041 }
6042
6043 // 8-directional movement, no alignment
6044 4691075 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6045 {
6046
9/12
✓ Branch 0 taken 4483752 times.
✓ Branch 1 taken 207323 times.
✓ Branch 2 taken 4483752 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4457131 times.
✓ Branch 5 taken 26621 times.
✓ Branch 6 taken 4446084 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4446084 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4446084 times.
4691075 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6047 244991 return;
6048
6049
2/2
✓ Branch 0 taken 4415704 times.
✓ Branch 1 taken 30380 times.
4446084 if(!canmove(dir,step,special,false))
6050 30380 clk3=0;
6051
6052
2/2
✓ Branch 0 taken 3891681 times.
✓ Branch 1 taken 554403 times.
4446084 if(clk3<=0)
6053 {
6054 554403 newdir_8(newrate,newhoming,special);
6055 554403 clk3=newclk;
6056 554403 }
6057
6058 4446084 --clk3;
6059 4446084 move(step);
6060 4691075 }
6061
6062 // same as above but with variable enemy size
6063 94563 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6064 {
6065
8/12
✓ Branch 0 taken 93367 times.
✓ Branch 1 taken 1196 times.
✓ Branch 2 taken 93367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93316 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93316 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93316 times.
94563 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6066 1247 return;
6067
6068
2/2
✓ Branch 0 taken 91982 times.
✓ Branch 1 taken 1334 times.
93316 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6069 1334 clk3=0;
6070
6071
2/2
✓ Branch 0 taken 86841 times.
✓ Branch 1 taken 6475 times.
93316 if(clk3<=0)
6072 {
6073 6475 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6074 6475 clk3=newclk;
6075 6475 }
6076
6077 93316 --clk3;
6078 93316 move(step);
6079 94563 }
6080
6081 // the variable speed floater movement
6082 // ms is max speed
6083 // ss is step speed
6084 // s is step count
6085 // p is pause count
6086 // g is graduality :)
6087 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6088 3989892 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6089 {
6090 3989892 ++clk2;
6091 3989892 byte over_pit = overpit(this);
6092
6093
4/4
✓ Branch 0 taken 1114794 times.
✓ Branch 1 taken 2875098 times.
✓ Branch 2 taken 1114527 times.
✓ Branch 3 taken 267 times.
3989892 if(dmisc1 && over_pit) p = 0;
6094
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56213 times.
✓ Branch 2 taken 1570783 times.
✓ Branch 3 taken 2230728 times.
✓ Branch 4 taken 132168 times.
3989892 switch(movestatus)
6095 {
6096 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6097 //! if the conditions prevent it, we jump back to case 2.
6098 case 0: // paused
6099
2/2
✓ Branch 0 taken 54765 times.
✓ Branch 1 taken 1448 times.
56213 if(clk2>=p)
6100 {
6101 1448 movestatus=1;
6102 1448 clk2=0;
6103 1448 }
6104
6105 56213 break;
6106
6107 case 1: // speeding up
6108
1/2
✓ Branch 0 taken 1570783 times.
✗ Branch 1 not taken.
1570783 if (s >= 0)
6109 {
6110
2/2
✓ Branch 0 taken 1559550 times.
✓ Branch 1 taken 11233 times.
1570783 if(clk2<g*s)
6111 {
6112
2/2
✓ Branch 0 taken 1458948 times.
✓ Branch 1 taken 100602 times.
1559550 if(!((clk2-1)%g))
6113 100602 step+=ss;
6114 1559550 }
6115 else
6116 {
6117 11233 movestatus=2;
6118 11233 clk2=0;
6119 }
6120 1570783 }
6121 else
6122 {
6123 if(step < ms)
6124 {
6125 if(!((clk2-1)%g))
6126 {
6127 step+=ss;
6128 if (step >= ms) step = ms;
6129 }
6130 }
6131 else
6132 {
6133 step = ms;
6134 movestatus=2;
6135 clk2=0;
6136 }
6137 }
6138
6139 1570783 break;
6140
6141 case 2: // normal
6142 2230728 step=ms;
6143
6144
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2230728 times.
✓ Branch 2 taken 477682 times.
✓ Branch 3 taken 1753046 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1753046 times.
✓ Branch 6 taken 1750807 times.
✓ Branch 7 taken 2239 times.
2230728 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6145 {
6146
1/2
✓ Branch 0 taken 2239 times.
✗ Branch 1 not taken.
2239 if (s >= 0) step=ss*s;
6147 else step=ms;
6148 2239 movestatus=3;
6149 2239 clk2=0;
6150 2239 }
6151
6152 2230728 break;
6153
6154 case 3: // slowing down
6155
1/2
✓ Branch 0 taken 132168 times.
✗ Branch 1 not taken.
132168 if (s >= 0)
6156 {
6157
2/2
✓ Branch 0 taken 130491 times.
✓ Branch 1 taken 1677 times.
132168 if(clk2<=g*s)
6158 {
6159 { //don't slow down over pits
6160
6161
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 130224 times.
130491 if(over_pit)
6162 {
6163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(dmisc1)
6164 {
6165 step=ms;
6166 }
6167 267 }
6168 else //can slow down
6169 {
6170
4/4
✓ Branch 0 taken 8036 times.
✓ Branch 1 taken 122188 times.
✓ Branch 2 taken 7668 times.
✓ Branch 3 taken 368 times.
130224 if(!(clk2%g) && !dmisc1)
6171 7668 step-=ss;
6172 }
6173 }
6174
6175
6176 130491 }
6177 else
6178 {
6179 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6180 //this doesn't help keese, as they have a z of 0.
6181 //they always nee to run this check.
6182 {
6183
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1677 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1677 if(over_pit &&!dmisc1)
6184 {
6185 --clk2; //if over a pit, don't land, and revert clock change
6186 }
6187 else //can land safely
6188 {
6189 1677 movestatus=0;
6190
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 562 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1677 if(dmisc1&&!over_pit)
6191 1115 step=0;
6192 1677 clk2=0;
6193 }
6194 }
6195
6196 }
6197 132168 }
6198 else
6199 {
6200 if(step > 0)
6201 {
6202 if(over_pit)
6203 {
6204 if(dmisc1)
6205 {
6206 step=ms;
6207 }
6208 }
6209 else //can slow down
6210 {
6211 if(!(clk2%g))
6212 step-=ss;
6213 }
6214 }
6215 else
6216 {
6217 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6218 //this doesn't help keese, as they have a z of 0.
6219 //they always nee to run this check.
6220 if(over_pit)
6221 {
6222 step+=ss; //if over a pit, don't land, and revert clock change
6223 }
6224 else //can land safely
6225 {
6226 movestatus=0;
6227 step=0;
6228 clk2=0;
6229 }
6230 }
6231 }
6232
6233 132168 break;
6234 }
6235
6236
2/2
✓ Branch 0 taken 2239722 times.
✓ Branch 1 taken 1750170 times.
3989892 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6237 3989892 }
6238
6239 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6240 {
6241 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6242 }
6243
6244 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6245 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6246 923665 int32_t enemy::lined_up(int32_t range, bool dir8)
6247 {
6248 923665 int32_t lx = Hero.getX();
6249 923665 int32_t ly = Hero.getY();
6250
6251
2/2
✓ Branch 0 taken 38487 times.
✓ Branch 1 taken 885178 times.
923665 if(abs(lx-int32_t(x))<=range)
6252 {
6253
2/2
✓ Branch 0 taken 16116 times.
✓ Branch 1 taken 22371 times.
38487 if(ly<y)
6254 {
6255 16116 return up;
6256 }
6257
6258 22371 return down;
6259 }
6260
6261
2/2
✓ Branch 0 taken 56294 times.
✓ Branch 1 taken 828884 times.
885178 if(abs(ly-int32_t(y))<=range)
6262 {
6263
2/2
✓ Branch 0 taken 30277 times.
✓ Branch 1 taken 26017 times.
56294 if(lx<x)
6264 {
6265 30277 return left;
6266 }
6267
6268 26017 return right;
6269 }
6270
6271
2/2
✓ Branch 0 taken 159834 times.
✓ Branch 1 taken 669050 times.
828884 if(dir8)
6272 {
6273
2/2
✓ Branch 0 taken 252160 times.
✓ Branch 1 taken 416890 times.
669050 if(abs(lx-x)-abs(ly-y)<=range)
6274 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6275 {
6276
2/2
✓ Branch 0 taken 105160 times.
✓ Branch 1 taken 147000 times.
252160 if(ly<y)
6277 {
6278
2/2
✓ Branch 0 taken 56622 times.
✓ Branch 1 taken 48538 times.
105160 if(lx<x)
6279 {
6280 56622 return l_up;
6281 }
6282 else
6283 {
6284 48538 return r_up;
6285 }
6286 }
6287 else
6288 {
6289
2/2
✓ Branch 0 taken 76220 times.
✓ Branch 1 taken 70780 times.
147000 if(lx<x)
6290 {
6291 70780 return l_down;
6292 }
6293 else
6294 {
6295 76220 return r_down;
6296 }
6297 }
6298 }
6299 416890 }
6300
6301 576724 return -1;
6302 923665 }
6303
6304 // returns true if Hero is within 'range' pixels of the enemy
6305 27884 bool enemy::HeroInRange(int32_t range)
6306 {
6307 27884 int32_t lx = Hero.getX();
6308 27884 int32_t ly = Hero.getY();
6309
2/2
✓ Branch 0 taken 22775 times.
✓ Branch 1 taken 5109 times.
27884 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6310 }
6311
6312 // place the enemy in line with Hero (red wizzrobes)
6313 4858 void enemy::place_on_axis(bool floater, bool solid_ok)
6314 {
6315
6/6
✓ Branch 0 taken 573 times.
✓ Branch 1 taken 4285 times.
✓ Branch 2 taken 4316 times.
✓ Branch 3 taken 542 times.
✓ Branch 4 taken 573 times.
✓ Branch 5 taken 3743 times.
4858 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6316
6/6
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 4421 times.
✓ Branch 2 taken 4082 times.
✓ Branch 3 taken 776 times.
✓ Branch 4 taken 437 times.
✓ Branch 5 taken 3645 times.
4858 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6317 4858 int32_t pos2=zc_oldrand()%23;
6318 4858 int32_t tried=0;
6319 4858 bool last_resort,placed=false;
6320
6321
6322 4858 do
6323 {
6324
2/2
✓ Branch 0 taken 4432 times.
✓ Branch 1 taken 3104 times.
7536 if(pos2<14)
6325 {
6326 4432 x=(pos2<<4)+16;
6327 4432 y=ly;
6328 4432 }
6329 else
6330 {
6331 3104 x=lx;
6332 3104 y=((pos2-14)<<4)+16;
6333 }
6334
6335 // Don't commit to a last resort if position is out of bounds.
6336
6/6
✓ Branch 0 taken 7199 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 6889 times.
✓ Branch 3 taken 310 times.
✓ Branch 4 taken 255 times.
✓ Branch 5 taken 6634 times.
7536 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6337
6338
4/4
✓ Branch 0 taken 3879 times.
✓ Branch 1 taken 3657 times.
✓ Branch 2 taken 4912 times.
✓ Branch 3 taken 1443 times.
7536 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6339 {
6340 // Red Wizzrobes should be able to appear on water, but not other
6341 // solid combos; however, they could appear on solid combos in 2.10,
6342 // and some quests depend on that.
6343
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6228 times.
✓ Branch 2 taken 1370 times.
✓ Branch 3 taken 4858 times.
8569 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6344 8569 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6345 4858 placed=true;
6346 8569 }
6347
6348
3/6
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 4662 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2678 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7340 if(!placed && tried>=22 && last_resort)
6349 {
6350 placed=true;
6351 }
6352
6353 7340 ++tried;
6354 7340 pos2=(pos2+3)%23;
6355
2/2
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 4662 times.
7340 }
6356 7340 while(!placed);
6357
6358
2/2
✓ Branch 0 taken 2872 times.
✓ Branch 1 taken 1790 times.
4662 if(y==ly)
6359 2872 dir=(x<lx)?right:left;
6360 else
6361 1790 dir=(y<ly)?down:up;
6362
6363 4662 clk2=tried;
6364 4662 }
6365
6366 20213685 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6367 {
6368 20213685 int32_t t = o_tile;
6369 20213685 int32_t b = o_tile;
6370
6371 // Darknuts, but also Wizzrobes and Wallmasters
6372
3/4
✓ Branch 0 taken 8353120 times.
✓ Branch 1 taken 10837883 times.
✓ Branch 2 taken 1022682 times.
✗ Branch 3 not taken.
20213685 switch(family)
6373 {
6374 case eeWALK:
6375
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10332476 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10837883 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6376 {
6377 367468 tile=s_tile;
6378 367468 t=s_tile;
6379 367468 b=s_tile;
6380 367468 }
6381
6382 10837883 break;
6383
6384 case eeTRAP:
6385
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 829116 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1022682 if(dummy_int[1] && guysbuf[id].flags2 & guy_trp2 && do_animation) // Just to make sure
6386 {
6387 193566 tile=s_tile;
6388 193566 t=s_tile;
6389 193566 b=s_tile;
6390 193566 }
6391
6392 1022682 break;
6393
6394 case eeSPINTILE:
6395 if(misc>=96 && do_animation)
6396 {
6397 tile=o_tile+frames*ndir;
6398 t=tile;
6399 }
6400
6401 break;
6402 }
6403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20213685 times.
20213685 if ( do_animation )
6404 {
6405
4/6
✓ Branch 0 taken 197042 times.
✓ Branch 1 taken 20016643 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19749512 times.
20213685 if(ndir!=0) switch(frames)
6406 {
6407 case 2:
6408 267131 tiledir_small(dir,ndir==4);
6409 267131 break;
6410
6411 case 3:
6412 tiledir_three(dir);
6413 break;
6414
6415 case 4:
6416 19749512 tiledir(dir,ndir==4);
6417 19749512 break;
6418 20016643 }
6419
6420
2/2
✓ Branch 0 taken 10837883 times.
✓ Branch 1 taken 9375802 times.
20213685 if(family==eeWALK)
6421
6/6
✓ Branch 0 taken 10776874 times.
✓ Branch 1 taken 61009 times.
✓ Branch 2 taken 8177902 times.
✓ Branch 3 taken 2659981 times.
✓ Branch 4 taken 2644258 times.
✓ Branch 5 taken 15723 times.
10837883 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6422 else
6423 9375802 tile+=f4;
6424 20213685 }
6425 20213685 return b;
6426 }
6427
6428 void enemy::tiledir_three(int32_t ndir)
6429 {
6430 if ( !do_animation ) return;
6431 flip=0;
6432
6433 switch(ndir)
6434 {
6435 case right:
6436 tile+=3;
6437 [[fallthrough]];
6438
6439 case left:
6440 tile+=3;
6441 [[fallthrough]];
6442
6443 case down:
6444 tile+=3;
6445 [[fallthrough]];
6446
6447 case up:
6448 break;
6449 }
6450 }
6451
6452 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6453 {
6454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6455 267131 flip=0;
6456
6457
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6458 {
6459 case 8:
6460 case up:
6461 53829 break;
6462
6463 case 12:
6464 case down:
6465 54679 tile+=2;
6466 54679 break;
6467
6468 case 14:
6469 case left:
6470 67727 tile+=4;
6471 67727 break;
6472
6473 case 10:
6474 case right:
6475 71182 tile+=6;
6476 71182 break;
6477
6478 case 9:
6479 case r_up:
6480
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6481 5706 break;
6482
6483 tile+=10;
6484 break;
6485
6486 case 11:
6487 case r_down:
6488
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6489 5154 tile+=2;
6490 else
6491 tile+=14;
6492
6493 5154 break;
6494
6495 case 13:
6496 case l_down:
6497
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6498 4872 tile+=2;
6499 else
6500 tile+=12;
6501
6502 4872 break;
6503
6504 case 15:
6505 case l_up:
6506
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6507 3982 break;
6508
6509 tile+=8;
6510 break;
6511
6512 default:
6513 //dir=(zc_oldrand()*100)%8;
6514 //tiledir_small(dir);
6515 // flip=zc_oldrand()&3;
6516 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6517 break;
6518 }
6519 267131 }
6520
6521 23069632 void enemy::tiledir(int32_t ndir, bool fourdir)
6522 {
6523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23069632 times.
23069632 if ( !do_animation ) return;
6524 23069632 flip=0;
6525
6526
9/9
✓ Branch 0 taken 4483892 times.
✓ Branch 1 taken 4141765 times.
✓ Branch 2 taken 5412757 times.
✓ Branch 3 taken 5175571 times.
✓ Branch 4 taken 825768 times.
✓ Branch 5 taken 1018734 times.
✓ Branch 6 taken 1099241 times.
✓ Branch 7 taken 845055 times.
✓ Branch 8 taken 66849 times.
23069632 switch(ndir)
6527 {
6528 case 8:
6529 case up:
6530 4483892 break;
6531
6532 case 12:
6533 case down:
6534 4141765 tile+=4;
6535 4141765 break;
6536
6537 case 14:
6538 case left:
6539 5412757 tile+=8;
6540 5412757 break;
6541
6542 case 10:
6543 case right:
6544 5175571 tile+=12;
6545 5175571 break;
6546
6547 case 9:
6548 case r_up:
6549
2/2
✓ Branch 0 taken 88653 times.
✓ Branch 1 taken 737115 times.
825768 if(fourdir)
6550 88653 break;
6551 else
6552 737115 tile+=24;
6553
6554 737115 break;
6555
6556 case 11:
6557 case r_down:
6558
2/2
✓ Branch 0 taken 101949 times.
✓ Branch 1 taken 916785 times.
1018734 if(fourdir)
6559 101949 tile+=4;
6560 else
6561 916785 tile+=32;
6562
6563 1018734 break;
6564
6565 case 13:
6566 case l_down:
6567
2/2
✓ Branch 0 taken 105945 times.
✓ Branch 1 taken 993296 times.
1099241 if(fourdir)
6568 105945 tile+=4;
6569 else
6570 993296 tile+=28;
6571
6572 1099241 break;
6573
6574 case 15:
6575 case l_up:
6576
2/2
✓ Branch 0 taken 82760 times.
✓ Branch 1 taken 762295 times.
845055 if(fourdir)
6577 82760 break;
6578 else
6579 762295 tile+=20;
6580
6581 762295 break;
6582
6583 default:
6584 //dir=(zc_oldrand()*100)%8;
6585 //tiledir(dir);
6586 // flip=zc_oldrand()&3;
6587 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6588 66849 break;
6589 }
6590 23069632 }
6591
6592 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6593 {
6594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6595 3868 flip=0;
6596
6597
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6598 {
6599 case 8:
6600 case up:
6601 297 break;
6602
6603 case 12:
6604 case down:
6605 tile+=8;
6606 break;
6607
6608 case 14:
6609 case left:
6610 195 tile+=40;
6611 195 break;
6612
6613 case 10:
6614 case right:
6615 179 tile+=48;
6616 179 break;
6617
6618 case 9:
6619 case r_up:
6620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6621 break;
6622
6623 306 tile+=88;
6624 306 break;
6625
6626 case 11:
6627 case r_down:
6628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6629 tile+=8;
6630 else
6631 1235 tile+=128;
6632
6633 1235 break;
6634
6635 case 13:
6636 case l_down:
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6638 tile+=8;
6639 else
6640 1324 tile+=120;
6641
6642 1324 break;
6643
6644 case 15:
6645 case l_up:
6646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6647 break;
6648
6649 332 tile+=80;
6650 332 break;
6651
6652 default:
6653 //dir=(zc_oldrand()*100)%8;
6654 //tiledir_big(dir);
6655 // flip=zc_oldrand()&3;
6656 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6657 break;
6658 }
6659 3868 }
6660
6661 39895319 void enemy::update_enemy_frame()
6662 {
6663
4/4
✓ Branch 0 taken 39893013 times.
✓ Branch 1 taken 2306 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 39893006 times.
39895319 if(fallclk||drownclk) return;
6664
1/2
✓ Branch 0 taken 39893006 times.
✗ Branch 1 not taken.
39893006 if (!do_animation)
6665 return;
6666
6667
4/4
✓ Branch 0 taken 1475933 times.
✓ Branch 1 taken 38417073 times.
✓ Branch 2 taken 1473926 times.
✓ Branch 3 taken 2007 times.
39893006 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6668
6669
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
39893006 if(get_qr(qr_ANONE_NOANIM)
6670
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39893006 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39893006 && anim == aNONE && family != eeGUY)
6671 return;
6672
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 39521630 times.
39893006 int32_t newfrate = zc_max(frate,4);
6673 39893006 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6674 39893006 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6675
2/2
✓ Branch 0 taken 29900304 times.
✓ Branch 1 taken 9992702 times.
39893006 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6676 39893006 tile = o_tile;
6677 39893006 int32_t basetile = o_tile;
6678 39893006 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6679 39893006 bool ignore_extend = false;
6680
35/40
✓ Branch 0 taken 220021 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 201224 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 140514 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4982387 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1519575 times.
✓ Branch 17 taken 197042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 686882 times.
✓ Branch 22 taken 1691672 times.
✓ Branch 23 taken 1133827 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4117708 times.
✓ Branch 27 taken 7475916 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 582791 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 880199 times.
✓ Branch 32 taken 218668 times.
✓ Branch 33 taken 1812060 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 6953976 times.
✓ Branch 37 taken 747030 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
39893006 switch(anim)
6681 {
6682
6683 case aDONGO:
6684 {
6685 69324 int32_t fr = stunclk>0 ? 16 : 8;
6686
6687
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6688 {
6689 // bloated
6690
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6691 {
6692 case up:
6693 960 tile+=9;
6694 960 flip=0;
6695 960 xofs=0;
6696 960 dummy_int[1]=0; //no additional tiles
6697 960 break;
6698
6699 case down:
6700 960 tile+=7;
6701 960 flip=0;
6702 960 xofs=0;
6703 960 dummy_int[1]=0; //no additional tiles
6704 960 break;
6705
6706 case left:
6707 1664 flip=1;
6708 1664 tile+=4;
6709 1664 xofs=16;
6710 1664 dummy_int[1]=1; //second tile is next tile
6711 1664 break;
6712
6713 case right:
6714 896 flip=0;
6715 896 tile+=5;
6716 896 xofs=16;
6717 896 dummy_int[1]=-1; //second tile is previous tile
6718 896 break;
6719 }
6720 4480 }
6721
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6722 {
6723 // normal
6724
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6725 {
6726 case up:
6727 13652 tile+=8;
6728 13652 flip=(clk&fr)?1:0;
6729 13652 xofs=0;
6730 13652 dummy_int[1]=0; //no additional tiles
6731 13652 break;
6732
6733 case down:
6734 15374 tile+=6;
6735 15374 flip=(clk&fr)?1:0;
6736 15374 xofs=0;
6737 15374 dummy_int[1]=0; //no additional tiles
6738 15374 break;
6739
6740 case left:
6741 19615 flip=1;
6742 19615 tile+=(clk&fr)?2:0;
6743 19615 xofs=16;
6744 19615 dummy_int[1]=1; //second tile is next tile
6745 19615 break;
6746
6747 case right:
6748 15086 flip=0;
6749 15086 tile+=(clk&fr)?3:1;
6750 15086 xofs=16;
6751 15086 dummy_int[1]=-1; //second tile is next tile
6752 15086 break;
6753 }
6754 63727 }
6755 }
6756 69324 break;
6757
6758 case aNEWDONGO:
6759 {
6760 53456 int32_t fr4=0;
6761
6762
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6763 {
6764 // bloated
6765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6766 {
6767 2752 fr4=3;
6768 2752 }
6769
6770
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6771 {
6772 2107 fr4=2;
6773 2107 }
6774
6775
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6776 {
6777 1419 fr4=1;
6778 1419 }
6779
6780
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6781 {
6782 731 fr4=0;
6783 731 }
6784
6785
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6786 {
6787 case up:
6788 256 xofs=0;
6789 256 tile+=8+fr4;
6790 256 dummy_int[1]=0; //no additional tiles
6791 256 break;
6792
6793 case down:
6794 576 xofs=0;
6795 576 tile+=12+fr4;
6796 576 dummy_int[1]=0; //no additional tiles
6797 576 break;
6798
6799 case left:
6800 704 tile+=29+(2*fr4);
6801 704 xofs=16;
6802 704 dummy_int[1]=-1; //second tile is previous tile
6803 704 break;
6804
6805 case right:
6806 1216 tile+=49+(2*fr4);
6807 1216 xofs=16;
6808 1216 dummy_int[1]=-1; //second tile is previous tile
6809 1216 break;
6810 }
6811 2752 }
6812
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6813 {
6814 // normal
6815
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6816 {
6817 case up:
6818 9234 xofs=0;
6819 9234 tile+=((clk&12)>>2);
6820 9234 dummy_int[1]=0; //no additional tiles
6821 9234 break;
6822
6823 case down:
6824 9871 xofs=0;
6825 9871 tile+=4+((clk&12)>>2);
6826 9871 dummy_int[1]=0; //no additional tiles
6827 9871 break;
6828
6829 case left:
6830 15025 tile+=21+((clk&12)>>1);
6831 15025 xofs=16;
6832 15025 dummy_int[1]=-1; //second tile is previous tile
6833 15025 break;
6834
6835 case right:
6836 15676 flip=0;
6837 15676 tile+=41+((clk&12)>>1);
6838 15676 xofs=16;
6839 15676 dummy_int[1]=-1; //second tile is previous tile
6840 15676 break;
6841 }
6842 49806 }
6843 }
6844 53456 break;
6845
6846 case aDONGOBS:
6847 {
6848 38833 int32_t fr4=0;
6849
6850
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6851 {
6852 // bloated
6853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6854 {
6855 2688 fr4=3;
6856 2688 }
6857
6858
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6859 {
6860 2058 fr4=2;
6861 2058 }
6862
6863
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6864 {
6865 1386 fr4=1;
6866 1386 }
6867
6868
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6869 {
6870 714 fr4=0;
6871 714 }
6872
6873
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6874 {
6875 case up:
6876 256 tile+=28+fr4;
6877 256 yofs+=8;
6878 256 dummy_int[1]=-20; //second tile change
6879 256 dummy_int[2]=0; //new xofs change
6880 256 dummy_int[3]=-16; //new xofs change
6881 256 break;
6882
6883 case down:
6884 384 tile+=12+fr4;
6885 384 yofs-=8;
6886 384 dummy_int[1]=20; //second tile change
6887 384 dummy_int[2]=0; //new xofs change
6888 384 dummy_int[3]=16; //new xofs change
6889 384 break;
6890
6891 case left:
6892 1024 tile+=49+(2*fr4);
6893 1024 xofs+=8;
6894 1024 dummy_int[1]=-1; //second tile change
6895 1024 dummy_int[2]=-16; //new xofs change
6896 1024 dummy_int[3]=0; //new xofs change
6897 1024 break;
6898
6899 case right:
6900 1024 tile+=69+(2*fr4);
6901 1024 xofs+=8;
6902 1024 dummy_int[1]=-1; //second tile change
6903 1024 dummy_int[2]=-16; //new xofs change
6904 1024 dummy_int[3]=0; //new xofs change
6905 1024 break;
6906 }
6907 2688 }
6908
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6909 {
6910 // normal
6911
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6912 {
6913 case up:
6914 7136 tile+=20+((clk&24)>>3);
6915 7136 yofs+=8;
6916 7136 dummy_int[1]=-20; //second tile change
6917 7136 dummy_int[2]=0; //new xofs change
6918 7136 dummy_int[3]=-16; //new xofs change
6919 7136 break;
6920
6921 case down:
6922 6672 tile+=4+((clk&24)>>3);
6923 6672 yofs-=8;
6924 6672 dummy_int[1]=20; //second tile change
6925 6672 dummy_int[2]=0; //new xofs change
6926 6672 dummy_int[3]=16; //new xofs change
6927 6672 break;
6928
6929 case left:
6930 11075 xofs=-8;
6931 11075 tile+=40+((clk&24)>>2);
6932 11075 dummy_int[1]=1; //second tile change
6933 11075 dummy_int[2]=16; //new xofs change
6934 11075 dummy_int[3]=0; //new xofs change
6935 11075 break;
6936
6937 case right:
6938 10601 tile+=60+((clk&24)>>2);
6939 10601 xofs=-8;
6940 10601 dummy_int[1]=1; //second tile change
6941 10601 dummy_int[2]=16; //new xofs change
6942 10601 dummy_int[3]=0; //new xofs change
6943 10601 break;
6944 }
6945 35484 }
6946 }
6947 38833 break;
6948
6949 case aWIZZ:
6950 {
6951 // if(d->misc1)
6952
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6953 {
6954
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6955 {
6956 91127 ++tile;
6957 91127 }
6958 182184 }
6959 else
6960 {
6961
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6962 {
6963 136489 ++tile;
6964 136489 }
6965 }
6966
6967
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6968 {
6969 case 9:
6970 case 15:
6971 case up:
6972 76094 tile+=2;
6973 76094 break;
6974
6975 case down:
6976 76591 break;
6977
6978 case 13:
6979 case left:
6980 157108 flip=1;
6981 157108 break;
6982
6983 default:
6984 145581 flip=0;
6985 145581 break;
6986 }
6987 }
6988 455374 break;
6989
6990 case aNEWWIZZ:
6991 {
6992 1519575 tiledir(dir,true);
6993
6994 // if(d->misc1) //walking wizzrobe
6995
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 777151 times.
1519575 if(dmisc1) //walking wizzrobe
6996 {
6997
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
6998 {
6999 369103 tile+=2;
7000 369103 }
7001
7002
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7003 {
7004 370339 tile+=1;
7005 370339 }
7006
7007
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7008 {
7009
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7010 {
7011 79162 tile+=40;
7012 79162 }
7013 742424 }
7014 742424 }
7015 else
7016 {
7017
4/4
✓ Branch 0 taken 710492 times.
✓ Branch 1 taken 66659 times.
✓ Branch 2 taken 167559 times.
✓ Branch 3 taken 542933 times.
777151 if(dummy_bool[1]||dummy_bool[2])
7018 {
7019 234218 tile+=20;
7020
7021
2/2
✓ Branch 0 taken 66650 times.
✓ Branch 1 taken 167568 times.
234218 if(dummy_bool[2])
7022 {
7023 167568 tile+=20;
7024 167568 }
7025 234218 }
7026
7027 777151 tile+=((frame>>1)&3);
7028 }
7029 }
7030 1519575 break;
7031
7032 case a3FRM:
7033 {
7034
2/2
✓ Branch 0 taken 46675 times.
✓ Branch 1 taken 150367 times.
197042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7035 }
7036 197042 break;
7037
7038 case a3FRM4DIR:
7039 {
7040 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7041 }
7042 break;
7043
7044 case aVIRE:
7045 {
7046
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7047 {
7048 29292 tile+=2;
7049 29292 }
7050
7051 128880 tile+=fx;
7052 }
7053 128880 break;
7054
7055 case aROPE:
7056 {
7057 220021 tile+=(1-fx);
7058 220021 flip = dir==left ? 1:0;
7059 }
7060 220021 break;
7061
7062 case aZORA:
7063 {
7064 int32_t dl;
7065
7066
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7067 {
7068 46739 dl=clk+5;
7069 46739 goto waves2;
7070 }
7071
7072
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7073
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7074 else
7075 {
7076 92458 dl=clk-36-66;
7077 waves2:
7078 139197 tile=((dl/11)&1)+s_tile;
7079 139197 basetile = s_tile;
7080 }
7081 }
7082 221637 break;
7083
7084 case aNEWZORA:
7085 {
7086 686882 f4=(clk/16)%4;
7087
7088 686882 tiledir(dir,true);
7089 int32_t dl;
7090
7091
4/4
✓ Branch 0 taken 485838 times.
✓ Branch 1 taken 201044 times.
✓ Branch 2 taken 249250 times.
✓ Branch 3 taken 236588 times.
686882 if((clk>35)&&(clk<36+67)) //surfaced
7092 {
7093
4/4
✓ Branch 0 taken 202239 times.
✓ Branch 1 taken 34349 times.
✓ Branch 2 taken 29164 times.
✓ Branch 3 taken 173075 times.
236588 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7094 {
7095 173075 tile+=80;
7096 173075 } //mouth closed
7097 else
7098 {
7099 63513 tile+=40;
7100 }
7101
7102 236588 tile+=f4;
7103 236588 }
7104 else
7105 {
7106
2/2
✓ Branch 0 taken 201044 times.
✓ Branch 1 taken 249250 times.
450294 if(clk<36)
7107 {
7108 201044 dl=clk+5;
7109 201044 }
7110 else
7111 {
7112 249250 dl=clk-36-66;
7113 }
7114
7115 450294 tile+=((dl/5)&3);
7116 }
7117 }
7118 686882 break;
7119
7120 case a4FRM4EYE:
7121 case a2FRM4EYE:
7122 case a4FRM8EYE:
7123 case a4FRM8EYEB: //big version
7124 case a4FRM4EYEB:
7125 {
7126 836734 tilerows = 2;
7127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7129 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7130 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7131 836734 int32_t lookat=zc_oldrand()&15;
7132
7133
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7134 {
7135 210774 lookat=l_down;
7136 210774 }
7137
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7138 {
7139 226850 lookat=down;
7140 226850 }
7141
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7142 {
7143 108837 lookat=r_down;
7144 108837 }
7145
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7146 {
7147 70395 lookat=right;
7148 70395 }
7149
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7150 {
7151 35067 lookat=r_up;
7152 35067 }
7153
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7154 {
7155 25436 lookat=up;
7156 25436 }
7157
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7158 {
7159 36803 lookat=l_up;
7160 36803 }
7161 else
7162 {
7163 122572 lookat=left;
7164 }
7165
7166 836734 int32_t dir2 = dir;
7167 836734 dir = lookat;
7168
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7169 else
7170 {
7171 tiledir_big(dir,(anim == a4FRM4EYEB));
7172 tile+=2*f4;
7173 ignore_extend = true;
7174 }
7175 836734 dir = dir2;
7176 }
7177 836734 break;
7178
7179 case aFLIP:
7180 {
7181 1691672 flip = f2&1;
7182 }
7183 1691672 break;
7184
7185 case a2FRM:
7186 {
7187 1133827 tile += (1-f2);
7188 }
7189 1133827 break;
7190
7191 case a2FRMB:
7192 {
7193 tile+= 2*(1-f2);
7194 ignore_extend = true;
7195 }
7196 break;
7197
7198 case a2FRM4DIR:
7199 {
7200 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7201 }
7202 267131 break;
7203
7204 case a4FRM4DIRF:
7205 {
7206 4117708 basetile = n_frame_n_dir(4,4,f4);
7207
7208
2/2
✓ Branch 0 taken 2717716 times.
✓ Branch 1 taken 1399992 times.
4117708 if(clk2>0) //stopped to fire
7209 {
7210 1399992 tile+=20;
7211
7212
2/2
✓ Branch 0 taken 697526 times.
✓ Branch 1 taken 702466 times.
1399992 if(clk2<17) //firing
7213 {
7214 702466 tile+=20;
7215 702466 }
7216 1399992 }
7217 }
7218 4117708 break;
7219
7220 case a4FRM4DIR:
7221 {
7222 7475916 basetile = n_frame_n_dir(4,4,f4);
7223 }
7224 7475916 break;
7225
7226 case a4FRM8DIRF:
7227 {
7228 tilerows = 2;
7229 basetile = n_frame_n_dir(4,8,f4);
7230
7231 if(clk2>0) //stopped to fire
7232 {
7233 tile+=40;
7234
7235 if(clk2<17) //firing
7236 {
7237 tile+=40;
7238 }
7239 }
7240 }
7241 break;
7242
7243 case a4FRM8DIRB:
7244 case a4FRM8DIRFB:
7245 {
7246 3868 tilerows = 2;
7247 3868 tiledir_big(dir,false);
7248 3868 tile+=2*f4;
7249
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7250 {
7251 tile+=80;
7252
7253 if(clk2<17) //firing
7254 {
7255 tile+=80;
7256 }
7257 }
7258 3868 ignore_extend = true;
7259 }
7260 3868 break;
7261
7262 case a4FRM4DIRB:
7263 case a4FRM4DIRFB:
7264 {
7265 tilerows = 2;
7266 tiledir_big(dir,true);
7267 tile+=2*f4;
7268 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7269 {
7270 tile+=40;
7271
7272 if(clk2<17) //firing
7273 {
7274 tile+=40;
7275 }
7276 }
7277 ignore_extend = true;
7278 }
7279 break;
7280
7281 case aOCTO:
7282 {
7283
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 122459 times.
✓ Branch 2 taken 133448 times.
✓ Branch 3 taken 165605 times.
✓ Branch 4 taken 157127 times.
582791 switch(dir)
7284 {
7285 case up:
7286 122459 flip = 2;
7287 122459 break;
7288
7289 case down:
7290 133448 flip = 0;
7291 133448 break;
7292
7293 case left:
7294 165605 flip = 0;
7295 165605 tile += 2;
7296 165605 break;
7297
7298 case right:
7299 157127 flip = 1;
7300 157127 tile += 2;
7301 157127 break;
7302 }
7303
7304 582791 tile+=f2;
7305 }
7306 582791 break;
7307
7308 case aWALK:
7309 {
7310
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7311 {
7312 case up:
7313 248704 tile+=3;
7314 248704 flip = f2;
7315 248704 break;
7316
7317 case down:
7318 267165 tile+=2;
7319 267165 flip = f2;
7320 267165 break;
7321
7322 case left:
7323 331694 flip=1;
7324 331694 tile += f2;
7325 331694 break;
7326
7327 case right:
7328 325802 flip=0;
7329 325802 tile += f2;
7330 325802 break;
7331 }
7332 }
7333 1178979 break;
7334
7335 case aDWALK:
7336 {
7337
3/4
✓ Branch 0 taken 92353 times.
✓ Branch 1 taken 787846 times.
✓ Branch 2 taken 92353 times.
✗ Branch 3 not taken.
880199 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7338 {
7339 tile=s_tile;
7340 basetile = s_tile;
7341 }
7342
7343
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 177728 times.
✓ Branch 2 taken 185581 times.
✓ Branch 3 taken 260962 times.
✓ Branch 4 taken 255928 times.
880199 switch(dir)
7344 {
7345 case up:
7346 177728 tile+=2;
7347 177728 flip=f2;
7348 177728 break;
7349
7350 case down:
7351 185581 flip=0;
7352 185581 tile+=(1-f2);
7353 185581 break;
7354
7355 case left:
7356 260962 flip=1;
7357 260962 tile+=(3+f2);
7358 260962 break;
7359
7360 case right:
7361 255928 flip=0;
7362 255928 tile+=(3+f2);
7363 255928 break;
7364 }
7365 }
7366 880199 break;
7367
7368 case aTEK:
7369 {
7370
2/2
✓ Branch 0 taken 139654 times.
✓ Branch 1 taken 79014 times.
218668 if(misc==0)
7371 {
7372 79014 tile += f2;
7373 79014 }
7374
2/2
✓ Branch 0 taken 72936 times.
✓ Branch 1 taken 66718 times.
139654 else if(misc!=1)
7375 {
7376 66718 ++tile;
7377 66718 }
7378 }
7379 218668 break;
7380
7381 case aNEWTEK:
7382 {
7383
2/2
✓ Branch 0 taken 474700 times.
✓ Branch 1 taken 1337360 times.
1812060 if(step<0) //up
7384 {
7385
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235321 times.
✓ Branch 2 taken 239379 times.
474700 switch(clk3)
7386 {
7387 case left:
7388 235321 flip=0;
7389 235321 tile+=20;
7390 235321 break;
7391
7392 case right:
7393 239379 flip=0;
7394 239379 tile+=24;
7395 239379 break;
7396 }
7397 474700 }
7398
2/2
✓ Branch 0 taken 54741 times.
✓ Branch 1 taken 1282619 times.
1337360 else if(step==0)
7399 {
7400
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40562 times.
✓ Branch 2 taken 14179 times.
54741 switch(clk3)
7401 {
7402 case left:
7403 40562 flip=0;
7404 40562 tile+=8;
7405 40562 break;
7406
7407 case right:
7408 14179 flip=0;
7409 14179 tile+=12;
7410 14179 break;
7411 }
7412 54741 } //down
7413 else
7414 {
7415
3/3
✓ Branch 0 taken 104875 times.
✓ Branch 1 taken 592792 times.
✓ Branch 2 taken 584952 times.
1282619 switch(clk3)
7416 {
7417 case left:
7418 592792 flip=0;
7419 592792 tile+=28;
7420 592792 break;
7421
7422 case right:
7423 584952 flip=0;
7424 584952 tile+=32;
7425 584952 break;
7426 }
7427 }
7428
7429
2/2
✓ Branch 0 taken 1232959 times.
✓ Branch 1 taken 579101 times.
1812060 if(misc==0)
7430 {
7431 579101 tile+=f4;
7432 579101 }
7433
2/2
✓ Branch 0 taken 577625 times.
✓ Branch 1 taken 655334 times.
1232959 else if(misc!=1)
7434 {
7435 655334 tile+=2;
7436 655334 }
7437 }
7438 1812060 break;
7439
7440 case aARMOS:
7441 {
7442
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7443 {
7444 5401 tile += fx;
7445
7446
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7447 1197 tile += 2;
7448 5401 }
7449 }
7450 8628 break;
7451
7452 case aARMOS4:
7453 {
7454
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 28875 times.
✓ Branch 2 taken 86028 times.
✓ Branch 3 taken 43591 times.
✓ Branch 4 taken 42730 times.
201224 switch(dir)
7455 {
7456 case up:
7457 28875 flip=0;
7458 28875 break;
7459
7460 case down:
7461 86028 flip=0;
7462 86028 tile+=4;
7463 86028 break;
7464
7465 case left:
7466 43591 flip=0;
7467 43591 tile+=8;
7468 43591 break;
7469
7470 case right:
7471 42730 flip=0;
7472 42730 tile+=12;
7473 42730 break;
7474 }
7475
7476
2/2
✓ Branch 0 taken 59706 times.
✓ Branch 1 taken 141518 times.
201224 if(!fading)
7477 {
7478 141518 tile+=f4;
7479 141518 }
7480 }
7481 201224 break;
7482
7483 case aGHINI:
7484 {
7485
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7486 {
7487 case 8:
7488 case 9:
7489 case up:
7490 28037 ++tile;
7491 28037 flip=0;
7492 28037 break;
7493
7494 case 15:
7495 452 ++tile;
7496 452 flip=1;
7497 452 break;
7498
7499 case 10:
7500 case 11:
7501 case right:
7502 32092 flip=1;
7503 32092 break;
7504
7505 default:
7506 72763 flip=0;
7507 72763 break;
7508 }
7509 }
7510 133344 break;
7511
7512 case a2FRMPOS:
7513 {
7514 1755010 tile+=posframe;
7515 }
7516 1755010 break;
7517
7518 case a4FRMPOS4DIR:
7519 {
7520 363745 basetile = n_frame_n_dir(4,4,0);
7521 // tile+=f2;
7522 363745 tile+=posframe;
7523 }
7524 363745 break;
7525
7526 case a4FRMPOS4DIRF:
7527 {
7528 1433 basetile = n_frame_n_dir(4,4,0);
7529
7530
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7531 {
7532 197 tile+=20;
7533
7534
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7535 {
7536 64 tile+=20;
7537 64 }
7538 197 }
7539
7540 // tile+=f2;
7541 1433 tile+=posframe;
7542 }
7543 1433 break;
7544
7545 case a4FRMPOS8DIR:
7546 {
7547 6953976 tilerows = 2;
7548 6953976 int32_t n = tile;
7549 6953976 basetile = n_frame_n_dir(4,8,0);
7550 // tile+=f2;
7551 6953976 tile+=posframe;
7552 }
7553 6953976 break;
7554
7555 case a4FRMPOS8DIRF:
7556 {
7557 tilerows = 2;
7558 basetile = n_frame_n_dir(4,8,0);
7559
7560 if(clk2>0) //stopped to fire
7561 {
7562 tile+=40;
7563
7564 if(clk2<17) //firing
7565 {
7566 tile+=40;
7567 }
7568 }
7569
7570 tile+=posframe;
7571 }
7572 break;
7573
7574 case aNEWLEV:
7575 {
7576 747030 tiledir(dir,true);
7577
7578
4/5
✓ Branch 0 taken 258994 times.
✓ Branch 1 taken 115368 times.
✓ Branch 2 taken 48980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 323688 times.
747030 switch(misc)
7579 {
7580 case -1:
7581 case 0:
7582 258994 return;
7583
7584 case 1:
7585
7586 // case 5: cs = d->misc2; break;
7587 case 5:
7588 115368 cs = dmisc2;
7589 115368 break;
7590
7591 case 2:
7592 case 4:
7593 48980 tile += 20;
7594 48980 break;
7595
7596 case 3:
7597 323688 tile += 40;
7598 323688 break;
7599 }
7600
7601 488036 tile+=f4;
7602 }
7603 488036 break;
7604
7605 case aLEV:
7606 {
7607 276997 f4 = ((clk/5)&1);
7608
7609
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7610 {
7611 case -1:
7612 case 0:
7613 127945 return;
7614
7615 case 1:
7616
7617 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7618 case 5:
7619 33336 tile += (f2) ? 1 : 0;
7620 33336 cs = dmisc2;
7621 33336 break;
7622
7623 case 2:
7624 case 4:
7625 14658 tile += 2;
7626 14658 break;
7627
7628 case 3:
7629 101058 tile += (f4) ? 4 : 3;
7630 101058 break;
7631 }
7632 }
7633 149052 break;
7634
7635 case aWALLM:
7636 {
7637
2/2
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 139764 times.
140514 if(!dummy_bool[1])
7638 {
7639 139764 tile += f2;
7640 139764 }
7641 }
7642 140514 break;
7643
7644 case aNEWWALLM:
7645 {
7646 366633 int32_t tempdir=0;
7647
7648
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7649 {
7650 case 1:
7651 case 2:
7652 43340 tempdir=clk3;
7653 43340 break;
7654
7655 case 3:
7656 case 4:
7657 case 5:
7658 38855 tempdir=dir;
7659 38855 break;
7660
7661 case 6:
7662 case 7:
7663 8438 tempdir=clk3^1;
7664 8438 break;
7665 }
7666
7667 366633 tiledir(tempdir,true);
7668
7669
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7670 {
7671 364725 tile+=f4;
7672 364725 }
7673 }
7674 366633 break;
7675
7676 case a4FRMNODIR:
7677 {
7678 171508 tile+=f4;
7679 }
7680 171508 break;
7681
7682 } // switch(d->anim)
7683
7684 // flashing
7685 // if(d->flags2 & guy_flashing)
7686
2/2
✓ Branch 0 taken 38762439 times.
✓ Branch 1 taken 743628 times.
39506067 if(flags2 & guy_flashing)
7687 {
7688 743628 cs = (frame&3) + 6;
7689 743628 }
7690
7691
2/2
✓ Branch 0 taken 39095119 times.
✓ Branch 1 taken 410948 times.
39506067 if(flags2&guy_transparent)
7692 {
7693 410948 drawstyle=1;
7694 410948 }
7695
7696 39506067 int32_t change = tile-basetile;
7697
7698
3/6
✓ Branch 0 taken 1944681 times.
✓ Branch 1 taken 37561386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1944681 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39506067 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7699 {
7700
2/2
✓ Branch 0 taken 1681508 times.
✓ Branch 1 taken 263173 times.
1944681 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7701 {
7702 1681508 tile=basetile+txsz*change;
7703 1681508 }
7704 else
7705 {
7706 263173 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7707 }
7708 1944681 }
7709 else
7710 {
7711 37561386 tile=basetile+change;
7712 }
7713 39895319 }
7714
7715 81077 int32_t wpnsfx(int32_t wpn)
7716 {
7717
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21754 times.
✓ Branch 2 taken 665 times.
✓ Branch 3 taken 29990 times.
✓ Branch 4 taken 17706 times.
✓ Branch 5 taken 10962 times.
81077 switch(wpn)
7718 {
7719 case ewFireTrail:
7720 case ewFlame:
7721 case ewFlame2Trail:
7722 case ewFlame2:
7723 21754 return WAV_FIRE;
7724
7725 case ewWind:
7726 case ewMagic:
7727 665 return WAV_WAND;
7728
7729 case ewIce:
7730 return WAV_ZN1ICE;
7731
7732 case ewRock:
7733
2/2
✓ Branch 0 taken 2848 times.
✓ Branch 1 taken 8114 times.
10962 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1ROCK;
7734 8114 break;
7735
7736 case ewFireball2:
7737 case ewFireball:
7738
2/2
✓ Branch 0 taken 2646 times.
✓ Branch 1 taken 27344 times.
29990 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1FIREBALL;
7739 27344 }
7740
7741 53164 return -1;
7742 81077 }
7743
7744 76630804 int32_t enemy::run_script(int32_t mode)
7745 {
7746
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 76630548 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
76630804 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7747
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76630548 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76630548 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7748 76630548 return RUNSCRIPT_OK;
7749 auto scrty = *get_scrtype();
7750 auto uid = getUID();
7751 if(!FFCore.doscript(scrty,uid))
7752 return RUNSCRIPT_OK;
7753 int32_t ret = RUNSCRIPT_OK;
7754 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7755 switch(mode)
7756 {
7757 case MODE_NORMAL:
7758 return ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7759 case MODE_WAITDRAW:
7760 if(waitdraw)
7761 {
7762 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7763 waitdraw = false;
7764 }
7765 break;
7766 }
7767 return ret;
7768 76630804 }
7769 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7770 {
7771 return al_map_rgba(255,0,0,opacity);
7772 }
7773
7774 // good guys, fires, fairy, and other non-enemies
7775 // based on enemy class b/c guys in dungeons act sort of like enemies
7776 // also easier to manage all the guys this way
7777 2179 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7778 2179 {
7779 2179 mainguy=mg;
7780 2179 canfreeze=false;
7781 2179 dir=down;
7782
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2179 times.
✓ Branch 2 taken 2179 times.
✗ Branch 3 not taken.
2179 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7783 2179 hxofs=2;
7784 2179 hzsz=8;
7785 2179 hit_width=12;
7786 2179 hit_height=17;
7787
7788
10/12
✓ Branch 0 taken 2179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2179 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 766 times.
✓ Branch 5 taken 1413 times.
✓ Branch 6 taken 744 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 277 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 17 times.
✓ Branch 11 taken 260 times.
2179 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
7789 {
7790 1919 superman = 1;
7791 1919 hxofs=1000;
7792 1919 }
7793 2179 }
7794
7795 938381 bool guy::animate(int32_t index)
7796 {
7797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 938381 times.
938381 if(switch_hooked) return enemy::animate(index);
7798
6/6
✓ Branch 0 taken 539203 times.
✓ Branch 1 taken 399178 times.
✓ Branch 2 taken 8215 times.
✓ Branch 3 taken 530988 times.
✓ Branch 4 taken 7017 times.
✓ Branch 5 taken 1198 times.
938381 if(mainguy && clk==0 && misc==0)
7799 {
7800 1198 setupscreen();
7801 1198 misc = 1;
7802 1198 }
7803
7804
4/4
✓ Branch 0 taken 539203 times.
✓ Branch 1 taken 399178 times.
✓ Branch 2 taken 538875 times.
✓ Branch 3 taken 328 times.
938381 if(mainguy && fadeclk==0)
7805 328 return true;
7806
7807 938053 hp=256; // good guys never die...
7808
7809
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 937131 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
938053 if(hclk && !clk2)
7810 {
7811 // but if they get hit...
7812 16 ++clk2; // only do this once
7813
7814
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7815 {
7816 7 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
7817 7 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
7818 7 }
7819 16 }
7820
7821 938053 return enemy::animate(index);
7822 938381 }
7823
7824 942518 void guy::draw(BITMAP *dest)
7825 {
7826 942518 update_enemy_frame();
7827
7828
6/6
✓ Branch 0 taken 543133 times.
✓ Branch 1 taken 399385 times.
✓ Branch 2 taken 22779 times.
✓ Branch 3 taken 520354 times.
✓ Branch 4 taken 10998 times.
✓ Branch 5 taken 11781 times.
942518 if(!mainguy || fadeclk<0 || fadeclk&1)
7829 930737 enemy::draw(dest);
7830 942518 }
7831
7832 763 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7833 763 {
7834 763 clk4=0;
7835
4/8
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 763 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 763 times.
✗ Branch 7 not taken.
763 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7836 // Spawn type
7837
2/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 763 times.
763 if(flags & guy_fade_flicker)
7838 {
7839 clk=0;
7840 superman = 1;
7841 fading=fade_flicker;
7842 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7843 dir=down;
7844
7845 if(!canmove(down,(zfix)8,spw_none,false))
7846 clk3=int32_t(13.0/step);
7847 }
7848
3/4
✓ Branch 0 taken 763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 680 times.
✓ Branch 3 taken 83 times.
763 else if(flags & guy_fade_instant)
7849 {
7850 83 clk=0;
7851 83 }
7852
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
763 if (SIZEflags != 0) init_size_flags();;
7853 763 }
7854
7855 167980 bool eFire::animate(int32_t index)
7856 {
7857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167980 times.
167980 if(switch_hooked) return enemy::animate(index);
7858
2/4
✓ Branch 0 taken 167980 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167980 times.
167980 if(fallclk||drownclk) return enemy::animate(index);
7859
2/2
✓ Branch 0 taken 166188 times.
✓ Branch 1 taken 1792 times.
167980 if(fading)
7860 {
7861
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1791 times.
1792 if(++clk4 > 60)
7862 {
7863 1 clk4=0;
7864 1 superman=0;
7865 1 fading=0;
7866
7867
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags2&guy_armos && z==0 && fakez==0)
7868 removearmos(x,y,ffcactivated);
7869
7870 1 clk2=0;
7871
7872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7873 {
7874 1 dir=0;
7875 1 y = y.getInt() & 0xF0;
7876 1 }
7877
7878 1 return Dead(index);
7879 }
7880
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1791 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1791 else if(flags2&guy_armos && z==0 && fakez==0 && clk==0)
7881 removearmos(x,y,ffcactivated);
7882 1791 }
7883
7884 167979 return enemy::animate(index);
7885 167980 }
7886
7887 352675 void eFire::draw(BITMAP *dest)
7888 {
7889 352675 update_enemy_frame();
7890 352675 enemy::draw(dest);
7891 352675 }
7892
7893 419 int32_t eFire::takehit(weapon *w, weapon* realweap)
7894 {
7895 419 int32_t wpnId = w->id;
7896 419 int32_t wpnDir = w->dir;
7897
7898
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
419 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7899 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7900 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7901 {
7902 shield = false;
7903 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7904
7905 if(get_qr(qr_BRKNSHLDTILES))
7906 o_tile=s_tile;
7907 }
7908
7909 419 int32_t ret = enemy::takehit(w,realweap);
7910 419 return ret;
7911 }
7912
7913 void eFire::break_shield()
7914 {
7915 if(!shield)
7916 return;
7917
7918 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7919 shield=false;
7920
7921 if(get_qr(qr_BRKNSHLDTILES))
7922 o_tile=s_tile;
7923 }
7924
7925 7314 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7926 7314 {
7927 7314 clk4=0;
7928
4/8
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7314 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7314 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7314 times.
✗ Branch 7 not taken.
7314 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7929
7930 // Spawn type
7931
2/4
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7314 times.
7314 if(flags & guy_fade_flicker)
7932 {
7933 clk=0;
7934 superman = 1;
7935 fading=fade_flicker;
7936 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7937 dir=down;
7938
7939 if(!canmove(down,(zfix)8,spw_none,false))
7940 clk3=int32_t(13.0/step);
7941 }
7942
3/4
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6133 times.
✓ Branch 3 taken 1181 times.
7314 else if(flags & guy_fade_instant)
7943 {
7944 1181 clk=0;
7945 1181 }
7946
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7307 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7314 if (SIZEflags != 0) init_size_flags();;
7947 7314 }
7948
7949 1872314 bool eOther::animate(int32_t index)
7950 {
7951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1872314 times.
1872314 if(switch_hooked) return enemy::animate(index);
7952
3/4
✓ Branch 0 taken 1870797 times.
✓ Branch 1 taken 1517 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1870797 times.
1872314 if(fallclk||drownclk) return enemy::animate(index);
7953
2/2
✓ Branch 0 taken 1862383 times.
✓ Branch 1 taken 8414 times.
1870797 if(fading)
7954 {
7955
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 8387 times.
8414 if(++clk4 > 60)
7956 {
7957 27 clk4=0;
7958 27 superman=0;
7959 27 fading=0;
7960
7961
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27 if(flags2&guy_armos && z==0 && fakez==0)
7962 removearmos(x,y,ffcactivated);
7963
7964 27 clk2=0;
7965
7966
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 2 times.
27 if(!canmove(down,(zfix)8,spw_none,false))
7967 {
7968 2 dir=0;
7969 2 y = y.getInt() & 0xF0;
7970 2 }
7971
7972 27 return Dead(index);
7973 }
7974
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8387 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8387 else if(flags2&guy_armos && z==0 && fakez==0 && clk==0)
7975 removearmos(x,y,ffcactivated);
7976 8387 }
7977
7978 1870770 return enemy::animate(index);
7979 1872314 }
7980
7981 1975750 void eOther::draw(BITMAP *dest)
7982 {
7983 1975750 update_enemy_frame();
7984 1975750 enemy::draw(dest);
7985 1975750 }
7986
7987 14188 int32_t eOther::takehit(weapon *w, weapon* realweap)
7988 {
7989 14188 int32_t wpnId = w->id;
7990 14188 int32_t wpnDir = w->dir;
7991
7992
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
14188 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7993 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7994 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7995 {
7996 shield = false;
7997 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7998
7999 if(get_qr(qr_BRKNSHLDTILES))
8000 o_tile=s_tile;
8001 }
8002
8003 14188 int32_t ret = enemy::takehit(w,realweap);
8004 14188 return ret;
8005 }
8006
8007 void eOther::break_shield()
8008 {
8009 if(!shield)
8010 return;
8011
8012 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8013 shield=false;
8014
8015 if(get_qr(qr_BRKNSHLDTILES))
8016 o_tile=s_tile;
8017 }
8018
8019
8020 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8021 {
8022 clk4=0;
8023 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8024
8025 // Spawn type
8026 if(flags & guy_fade_flicker)
8027 {
8028 clk=0;
8029 superman = 1;
8030 fading=fade_flicker;
8031 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8032 dir=down;
8033
8034 if(!canmove(down,(zfix)8,spw_none,false))
8035 clk3=int32_t(13.0/step);
8036 }
8037 else if(flags & guy_fade_instant)
8038 {
8039 clk=0;
8040 }
8041 if (SIZEflags != 0) init_size_flags();;
8042 }
8043
8044 bool eScript::animate(int32_t index)
8045 {
8046 if(switch_hooked) return enemy::animate(index);
8047 if(fallclk||drownclk) return enemy::animate(index);
8048 if(fading)
8049 {
8050 if(++clk4 > 60)
8051 {
8052 clk4=0;
8053 superman=0;
8054 fading=0;
8055
8056 if(flags2&guy_armos && z==0 && fakez==0)
8057 removearmos(x,y,ffcactivated);
8058
8059 clk2=0;
8060
8061 if(!canmove(down,(zfix)8,spw_none,false))
8062 {
8063 dir=0;
8064 y = y.getInt() & 0xF0;
8065 }
8066
8067 return Dead(index);
8068 }
8069 else if(flags2&guy_armos && z==0 && fakez==0 && clk==0)
8070 removearmos(x,y,ffcactivated);
8071 }
8072
8073 return enemy::animate(index);
8074 }
8075
8076 void eScript::draw(BITMAP *dest)
8077 {
8078 update_enemy_frame();
8079 enemy::draw(dest);
8080 }
8081
8082 int32_t eScript::takehit(weapon *w, weapon* realweap)
8083 {
8084 int32_t wpnId = w->id;
8085 int32_t wpnDir = w->dir;
8086
8087 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8088 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8089 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8090 {
8091 shield = false;
8092 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8093
8094 if(get_qr(qr_BRKNSHLDTILES))
8095 o_tile=s_tile;
8096 }
8097
8098 int32_t ret = enemy::takehit(w,realweap);
8099 return ret;
8100 }
8101
8102 void eScript::break_shield()
8103 {
8104 if(!shield)
8105 return;
8106
8107 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8108 shield=false;
8109
8110 if(get_qr(qr_BRKNSHLDTILES))
8111 o_tile=s_tile;
8112 }
8113
8114
8115 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8116 {
8117 clk4=0;
8118 hyofs = -32768; //No hitbox initially.
8119 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8120
8121 // Spawn type
8122 if(flags & guy_fade_flicker)
8123 {
8124 clk=0;
8125 superman = 1;
8126 fading=fade_flicker;
8127 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8128 dir=down;
8129
8130 if(!canmove(down,(zfix)8,spw_none,false))
8131 clk3=int32_t(13.0/step);
8132 }
8133 else if(flags & guy_fade_instant)
8134 {
8135 clk=0;
8136 }
8137 if (SIZEflags != 0) init_size_flags();;
8138 }
8139
8140 bool eFriendly::animate(int32_t index)
8141 {
8142 if(switch_hooked) return enemy::animate(index);
8143 if(fallclk||drownclk) return enemy::animate(index);
8144 if(fading)
8145 {
8146 if(++clk4 > 60)
8147 {
8148 clk4=0;
8149 superman=0;
8150 fading=0;
8151
8152 if(flags2&guy_armos && z==0 && fakez==0)
8153 removearmos(x,y,ffcactivated);
8154
8155 clk2=0;
8156
8157 if(!canmove(down,(zfix)8,spw_none,false))
8158 {
8159 dir=0;
8160 y = y.getInt() & 0xF0;
8161 }
8162
8163 return Dead(index);
8164 }
8165 else if(flags2&guy_armos && z==0 && fakez==0 && clk==0)
8166 removearmos(x,y,ffcactivated);
8167 }
8168
8169 return enemy::animate(index);
8170 }
8171
8172 void eFriendly::draw(BITMAP *dest)
8173 {
8174 update_enemy_frame();
8175 enemy::draw(dest);
8176 }
8177
8178 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8179 {
8180 int32_t wpnId = w->id;
8181 int32_t wpnDir = w->dir;
8182
8183 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8184 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8185 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8186 {
8187 shield = false;
8188 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8189
8190 if(get_qr(qr_BRKNSHLDTILES))
8191 o_tile=s_tile;
8192 }
8193
8194 int32_t ret = enemy::takehit(w,realweap);
8195 return ret;
8196 }
8197
8198 void eFriendly::break_shield()
8199 {
8200 if(!shield)
8201 return;
8202
8203 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8204 shield=false;
8205
8206 if(get_qr(qr_BRKNSHLDTILES))
8207 o_tile=s_tile;
8208 }
8209
8210
8211 779127 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
8212 {
8213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779127 times.
779127 if (ffcactive)
8214 {
8215 removearmosffc(ffcactive-1);
8216 return;
8217 }
8218
2/2
✓ Branch 0 taken 778147 times.
✓ Branch 1 taken 980 times.
779127 if(did_armos)
8219 {
8220 778147 return;
8221 }
8222
8223 980 did_armos=true;
8224 980 ax&=0xF0;
8225 980 ay&=0xF0;
8226 980 int32_t cd = (ax>>4)+ay;
8227 980 int32_t f = MAPFLAG(ax,ay);
8228 980 int32_t f2 = MAPCOMBOFLAG(ax,ay);
8229
8230
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 140 times.
980 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
8231 {
8232 840 return;
8233 }
8234
8235 140 tmpscr->data[cd] = tmpscr->undercombo;
8236 140 tmpscr->cset[cd] = tmpscr->undercset;
8237 140 tmpscr->sflag[cd] = 0;
8238
8239
3/4
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 118 times.
140 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8240 {
8241 22 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
8242 22 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
8243 22 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
8244 22 sfx(tmpscr->secretsfx);
8245 22 }
8246
8247
3/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 137 times.
140 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8248 {
8249
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8250 {
8251 3 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8252 3 sfx(tmpscr->secretsfx);
8253 3 }
8254 3 }
8255
8256 140 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
8257 779127 }
8258
8259 void enemy::removearmosffc(int32_t pos)
8260 {
8261 if(did_armos)
8262 {
8263 return;
8264 }
8265
8266 did_armos=true;
8267 ffcdata& ffc = tmpscr->ffcs[pos];
8268 newcombo const& cmb = combobuf[ffc.data];
8269 int32_t f2 = cmb.flag;
8270
8271 if(cmb.type!=cARMOS)
8272 {
8273 return;
8274 }
8275
8276 zc_ffc_set(ffc, tmpscr->undercombo);
8277 ffc.cset = tmpscr->undercset;
8278
8279 if(f2 == mfARMOS_SECRET)
8280 {
8281 zc_ffc_set(ffc, tmpscr->secretcombo[sSTAIRS]);
8282 ffc.cset = tmpscr->secretcset[sSTAIRS];
8283 sfx(tmpscr->secretsfx);
8284 }
8285
8286 if(f2 == mfARMOS_ITEM)
8287 {
8288 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8289 {
8290 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8291 sfx(tmpscr->secretsfx);
8292 }
8293 }
8294
8295 putcombo(scrollbuf,ffc.x,ffc.y,ffc.data,ffc.cset);
8296 }
8297
8298
8299 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8300 461 {
8301 461 fading=fade_flicker;
8302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8303 461 dir=12;
8304 461 movestatus=1;
8305
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8306 461 clk=0;
8307 461 clk4=0;
8308
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8309 461 }
8310
8311 117025 bool eGhini::animate(int32_t index)
8312 {
8313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8314
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8315
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8316 50 return Dead(index);
8317
8318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8319 {
8320
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8321 {
8322
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8323 54853 misc=2;
8324
8325
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8326 89752 removearmos(x,y,ffcactivated);
8327 89752 }
8328
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8329 {
8330 425 misc=1;
8331 425 clk3=32;
8332 425 fading=0;
8333
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if (ffcactivated > 0)
8334 {
8335 guygridffc[ffcactivated-1] = 0;
8336 removearmosffc(ffcactivated-1);
8337 }
8338 else
8339 {
8340 425 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
8341 425 removearmos(x,y);
8342 }
8343 425 }
8344 116975 }
8345
8346 116975 clk4++;
8347
8348 116975 return enemy::animate(index);
8349 117025 }
8350
8351 238808 void eGhini::draw(BITMAP *dest)
8352 {
8353 238808 update_enemy_frame();
8354 238808 enemy::draw(dest);
8355 238808 }
8356
8357 2 void eGhini::kickbucket()
8358 {
8359 2 hp=-1000; // don't call death_sfx()
8360 2 }
8361
8362
2/4
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5196 times.
✗ Branch 3 not taken.
10392 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8363 5196 {
8364
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 old_y=y;
8365 5196 dir=down;
8366 5196 misc=1;
8367 5196 clk=-15;
8368
8369
2/2
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 2551 times.
5196 if(!BSZ)
8370
1/2
✓ Branch 0 taken 2645 times.
✗ Branch 1 not taken.
2645 clk*=zc_oldrand()%3+1;
8371
8372 // avoid divide by 0 errors
8373
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 if(dmisc1 == 0)
8374 dmisc1 = 24;
8375
8376
1/2
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
5196 if(dmisc2 == 0)
8377 dmisc2 = 3;
8378
8379 //nets+760;
8380
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5196 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5196 if (SIZEflags != 0) init_size_flags();;
8381 5196 }
8382
8383 1435270 bool eTektite::animate(int32_t index)
8384 {
8385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1435270 times.
1435270 if(switch_hooked) return enemy::animate(index);
8386
4/4
✓ Branch 0 taken 1426328 times.
✓ Branch 1 taken 8942 times.
✓ Branch 2 taken 8942 times.
✓ Branch 3 taken 1423910 times.
1435270 if(fallclk||drownclk) return enemy::animate(index);
8387
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1397243 times.
1423910 if(dying)
8388 26667 return Dead(index);
8389
8390
2/2
✓ Branch 0 taken 1360175 times.
✓ Branch 1 taken 37068 times.
1397243 if(clk==0)
8391 {
8392 37068 removearmos(x,y,ffcactivated);
8393 37068 }
8394
8395
2/2
✓ Branch 0 taken 1056060 times.
✓ Branch 1 taken 341183 times.
1397243 if(get_qr(qr_ENEMIESZAXIS))
8396 {
8397 341183 y=floor_y;
8398 341183 }
8399
8400
9/10
✓ Branch 0 taken 1282576 times.
✓ Branch 1 taken 114667 times.
✓ Branch 2 taken 1269012 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1269012 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1257836 times.
✓ Branch 8 taken 11976 times.
✓ Branch 9 taken 21878 times.
1397243 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8401 {
8402
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421148 times.
✓ Branch 2 taken 344884 times.
✓ Branch 3 taken 493422 times.
1279714 switch(misc)
8403 {
8404 case 0: // normal
8405
2/2
✓ Branch 0 taken 409927 times.
✓ Branch 1 taken 11221 times.
421148 if(!(zc_oldrand()%dmisc1))
8406 {
8407 11221 misc=1;
8408 11221 clk2=32;
8409 11221 }
8410
8411 421148 break;
8412
8413 case 1: // waiting to pounce
8414
2/2
✓ Branch 0 taken 324265 times.
✓ Branch 1 taken 20619 times.
344884 if(--clk2<=0)
8415 {
8416 20619 int32_t r=zc_oldrand();
8417 20619 misc=2;
8418 20619 step=0-(zslongToFix(dstep*100)); // initial speed
8419 20619 clk3=(r&1)+2; // left or right
8420 20619 clk2start=clk2=(r&31)+10; // flight time
8421
8422
2/2
✓ Branch 0 taken 18196 times.
✓ Branch 1 taken 2423 times.
20619 if(y<32) clk2+=2; // make them come down from top of screen
8423
8424
2/2
✓ Branch 0 taken 15702 times.
✓ Branch 1 taken 4917 times.
20619 if(y>112) clk2-=2; // make them go back up
8425
8426 20619 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8427 20619 }
8428
8429 344884 break;
8430
8431 case 2: // in flight
8432 493422 move(step);
8433
8434
2/2
✓ Branch 0 taken 234221 times.
✓ Branch 1 taken 259201 times.
493422 if(step>0) //going down
8435 {
8436
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 233589 times.
234221 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8437 {
8438 632 step=0-step;
8439 632 }
8440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233589 times.
233589 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8441 {
8442 step=0-step;
8443 }
8444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233589 times.
233589 else if(ispitfall(x+8,y+16))
8445 {
8446 step=0-step;
8447 }
8448
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233542 times.
233589 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8449 {
8450 47 step=0-step;
8451 47 }
8452
2/2
✓ Branch 0 taken 233531 times.
✓ Branch 1 taken 11 times.
233542 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8453 {
8454 11 step=0-step;
8455 11 }
8456 234221 }
8457
2/2
✓ Branch 0 taken 15154 times.
✓ Branch 1 taken 244047 times.
259201 else if(step<0)
8458 {
8459
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243609 times.
244047 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8460 {
8461 438 step=0-step;
8462 438 }
8463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243609 times.
243609 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8464 {
8465 step=0-step;
8466 }
8467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243609 times.
243609 else if(ispitfall(x+8,y))
8468 {
8469 step=0-step;
8470 }
8471
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243588 times.
243609 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8472 {
8473 21 step=0-step;
8474 21 }
8475
2/2
✓ Branch 0 taken 243569 times.
✓ Branch 1 taken 19 times.
243588 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8476 {
8477 19 step=0-step;
8478 19 }
8479 244047 }
8480
8481
2/2
✓ Branch 0 taken 244152 times.
✓ Branch 1 taken 249270 times.
493422 if(clk3==left)
8482 {
8483
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 243877 times.
244152 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8484 {
8485 275 clk3^=1;
8486 275 }
8487
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 243871 times.
243877 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8488 {
8489 6 clk3^=1;
8490 6 }
8491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243871 times.
243871 else if(ispitfall(x,y+8))
8492 {
8493 clk3^=1;
8494 }
8495
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 243841 times.
243871 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8496 {
8497 30 clk3^=1;
8498 30 }
8499
2/2
✓ Branch 0 taken 243829 times.
✓ Branch 1 taken 12 times.
243841 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8500 {
8501 12 clk3^=1;
8502 12 }
8503 244152 }
8504 else
8505 {
8506
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 248994 times.
249270 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8507 {
8508 276 clk3^=1;
8509 276 }
8510
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 248982 times.
248994 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8511 {
8512 12 clk3^=1;
8513 12 }
8514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248982 times.
248982 else if(ispitfall(x+16,y+8))
8515 {
8516 clk3^=1;
8517 }
8518
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 248977 times.
248982 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8519 {
8520 5 clk3^=1;
8521 5 }
8522
2/2
✓ Branch 0 taken 248965 times.
✓ Branch 1 taken 12 times.
248977 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8523 {
8524 12 clk3^=1;
8525 12 }
8526 }
8527
8528 493422 --c;
8529
8530
4/4
✓ Branch 0 taken 151408 times.
✓ Branch 1 taken 342014 times.
✓ Branch 2 taken 320475 times.
✓ Branch 3 taken 172947 times.
493422 if(c<0 && step<zslongToFix(dstep*100))
8531 {
8532 172947 step+=zslongToFix(dmisc3*100);
8533 172947 }
8534
8535 493422 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8536
8537
2/2
✓ Branch 0 taken 492701 times.
✓ Branch 1 taken 721 times.
493422 if(x<=16-nb) clk3=right;
8538
8539
2/2
✓ Branch 0 taken 492430 times.
✓ Branch 1 taken 992 times.
493422 if(x>=224+nb) clk3=left;
8540
8541 493422 x += (clk3==left) ? -1 : 1;
8542
8543
4/4
✓ Branch 0 taken 29025 times.
✓ Branch 1 taken 464397 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454267 times.
493422 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
8544 {
8545
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17274 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39155 if(y>=144+nb && get_qr(qr_ENEMIESZAXIS))
8546 {
8547 185 step=0-step;
8548 185 y--;
8549 185 }
8550
2/2
✓ Branch 0 taken 5794 times.
✓ Branch 1 taken 12916 times.
18710 else if(zc_oldrand()%dmisc2) //land and wait
8551 {
8552 12916 clk=misc=0;
8553 12916 } //land and jump again
8554 else
8555 {
8556 5794 misc=1;
8557 5794 clk2=0;
8558 }
8559 18895 }
8560
8561 473162 break;
8562 } // switch
8563 1259454 }
8564
8565
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1058478 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1399661 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8566 {
8567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & move_use_fake_z)
8568 {
8569 int32_t tempy = floor_y;
8570 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8571 floor_y = y;
8572 y=tempy-fakez;
8573 old_y = y;
8574 }
8575 else
8576 {
8577 109977 int32_t tempy = floor_y;
8578
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8579 109977 floor_y = y;
8580 109977 y=tempy-z;
8581 109977 old_y = y;
8582 }
8583 109977 }
8584
8585
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1386097 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1399661 if(stunclk && (clk&31)==1)
8586 10637 clk=0;
8587
8588 1399661 return enemy::animate(index);
8589 1426328 }
8590
8591 803206 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8592 {
8593
5/6
✓ Branch 0 taken 625928 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 625928 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 600737 times.
✓ Branch 5 taken 25191 times.
803206 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8594 25191 return;
8595
8596 778015 int32_t tempy=yofs;
8597 778015 int32_t fdiv = frate/4;
8598
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8599
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8600 778015 efrate:((clk>=(frate>>1))?1:0);
8601 778015 flip = 0;
8602 778015 shadowtile = wpnsbuf[spr_shadow].tile;
8603
8604
1/2
✓ Branch 0 taken 778015 times.
✗ Branch 1 not taken.
778015 if(get_qr(qr_NEWENEMYTILES))
8605 {
8606
2/2
✓ Branch 0 taken 575932 times.
✓ Branch 1 taken 202083 times.
778015 if(misc==0)
8607 {
8608 202083 shadowtile+=f2;
8609 202083 }
8610
2/2
✓ Branch 0 taken 254903 times.
✓ Branch 1 taken 321029 times.
575932 else if(misc!=1)
8611 321029 shadowtile+=2;
8612 778015 }
8613 else
8614 {
8615 if(misc==0)
8616 {
8617 shadowtile += f2 ? 1 : 0;
8618 }
8619 else if(misc!=1)
8620 {
8621 ++shadowtile;
8622 }
8623 }
8624
8625 778015 yofs+=8;
8626
8627
4/4
✓ Branch 0 taken 600737 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 339908 times.
✓ Branch 3 taken 260829 times.
778015 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8628 {
8629
6/6
✓ Branch 0 taken 134073 times.
✓ Branch 1 taken 126756 times.
✓ Branch 2 taken 243385 times.
✓ Branch 3 taken 17444 times.
✓ Branch 4 taken 123475 times.
✓ Branch 5 taken 119910 times.
260829 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8630 260829 }
8631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 778015 times.
778015 if(!shadow_overpit(this))
8632 778015 enemy::drawshadow(dest,translucent);
8633 778015 yofs=tempy;
8634 803206 }
8635
8636 2045360 void eTektite::draw(BITMAP *dest)
8637 {
8638 2045360 update_enemy_frame();
8639 2045360 enemy::draw(dest);
8640 2045360 }
8641
8642 730 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8643 730 {
8644
2/4
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
730 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8645 730 superman=1;
8646 730 dir=8;
8647 730 hxofs=1000;
8648 730 mainguy=false;
8649 730 count_enemy=false;
8650
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
730 if (SIZEflags != 0) init_size_flags();;
8651 730 }
8652
8653 279897 bool eItemFairy::animate(int32_t index)
8654 {
8655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279897 times.
279897 if(switch_hooked) return enemy::animate(index);
8656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279897 times.
279897 if(dying)
8657 return Dead(index);
8658
8659 //if(clk>32)
8660 279897 misc=1;
8661 279897 bool w=watch;
8662 279897 watch=false;
8663 279897 variable_walk_8(misc?3:0,0,8,spw_floater);
8664 279897 watch=w;
8665
8666
2/2
✓ Branch 0 taken 1514 times.
✓ Branch 1 taken 278383 times.
279897 if(clk==0)
8667 {
8668 1514 removearmos(x,y,ffcactivated);
8669 1514 }
8670
8671 279897 return enemy::animate(index);
8672 279897 }
8673
8674 562150 void eItemFairy::draw(BITMAP *dest)
8675 {
8676 //these are here to bypass compiler warnings about unused arguments
8677 562150 dest=dest;
8678 562150 }
8679
8680 1825 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8681 1825 {
8682 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8683
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1825 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1825 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1825 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1825 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1825 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1825 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1825 times.
✗ Branch 19 not taken.
1825 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8684 1825 dir=8;
8685 1825 movestatus=1;
8686 1825 clk=0;
8687
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 step=0;
8688 //nets+720;
8689
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if (SIZEflags != 0) init_size_flags();;
8690 1825 }
8691
8692 520615 bool ePeahat::animate(int32_t index)
8693 {
8694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520615 times.
520615 if(switch_hooked) return enemy::animate(index);
8695
2/4
✓ Branch 0 taken 520615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520615 times.
520615 if(fallclk||drownclk) return enemy::animate(index);
8696
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 520537 times.
520615 if(slide())
8697 {
8698 78 return false;
8699 }
8700
8701
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 519507 times.
520537 if(dying)
8702 1030 return Dead(index);
8703
8704
2/2
✓ Branch 0 taken 3083 times.
✓ Branch 1 taken 516424 times.
519507 if(clk==0)
8705 {
8706 3083 removearmos(x,y,ffcactivated);
8707 3083 }
8708
8709
4/4
✓ Branch 0 taken 516389 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 253336 times.
✓ Branch 3 taken 263053 times.
519507 if(stunclk==0 && clk>96)
8710 263053 misc=1;
8711
8712
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
519507 if(!watch)
8713
2/2
✓ Branch 0 taken 171491 times.
✓ Branch 1 taken 345614 times.
517105 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8714
8715
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
519507 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8716 {
8717
1/2
✓ Branch 0 taken 100018 times.
✗ Branch 1 not taken.
100018 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8718 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8719 100018 }
8720
8721
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
519507 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8722 1634 superman=0;
8723 else
8724
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 508062 times.
517873 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8725 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8726
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 254570 times.
519507 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8727 {
8728
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8729 264937 }
8730 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8731 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8732
8733
8734
2/2
✓ Branch 0 taken 519267 times.
✓ Branch 1 taken 240 times.
519507 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8735
8736 519507 return enemy::animate(index);
8737 520615 }
8738
8739 334520 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8740 {
8741 334520 int32_t tempy=yofs;
8742 334520 flip = 0;
8743 334520 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8744
8745
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 246431 times.
334520 if(!get_qr(qr_ENEMIESZAXIS))
8746 {
8747 246431 yofs+=8;
8748 246431 yofs+=int32_t(step/zslongToFix(dstep*10));
8749 246431 }
8750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334520 times.
334520 if(!shadow_overpit(this))
8751 334520 enemy::drawshadow(dest,translucent);
8752 334520 yofs=tempy;
8753 334520 }
8754
8755 1144330 void ePeahat::draw(BITMAP *dest)
8756 {
8757 1144330 update_enemy_frame();
8758 1144330 enemy::draw(dest);
8759 1144330 }
8760
8761 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8762 {
8763 4136 int32_t wpnId = w->id;
8764 4136 int32_t enemyHitWeapon = w->parentitem;
8765
8766
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8767 return 0;
8768
8769
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8770 // fire boomerang, for nailing peahats
8771
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8772 3343 return 0;
8773
8774 // Time for a kludge...
8775 793 int32_t s = superman;
8776 793 superman = 0;
8777 793 int32_t ret = enemy::takehit(w,realweap);
8778 793 superman = s;
8779
8780 // Anyway...
8781
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8782 {
8783 192 clk2=0;
8784 192 movestatus=0;
8785 192 misc=0;
8786 192 clk=0;
8787 192 step=0;
8788 192 }
8789
8790 793 return ret;
8791 4136 }
8792
8793 // auomatically kill off enemy (for rooms with ringleaders)
8794 void ePeahat::kickbucket()
8795 {
8796 hp=-1000; // don't call death_sfx()
8797 }
8798
8799 3942 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8800 3942 {
8801 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8802
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 2147 times.
3942 if(dmisc1==0)
8803 {
8804 2147 misc=-1; //Line of Sight leevers
8805 2147 clk-=16;
8806 2147 }
8807 3942 clk3 = 0;
8808 //nets+1460;
8809 3942 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8810 3942 submerged = false;
8811
1/4
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if (SIZEflags != 0) init_size_flags();;
8812 3942 }
8813
8814 923 bool eLeever::isSubmerged() const
8815 {
8816 923 Z_scripterrlog("misc is: %d\n", misc);
8817 923 return misc <= 0;
8818
8819 }
8820
8821 1018478 bool eLeever::animate(int32_t index)
8822 {
8823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018478 times.
1018478 if(switch_hooked) return enemy::animate(index);
8824
3/4
✓ Branch 0 taken 1018123 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018123 times.
1018478 if(fallclk||drownclk)
8825 {
8826 355 return enemy::animate(index);
8827 }
8828
2/2
✓ Branch 0 taken 31552 times.
✓ Branch 1 taken 986571 times.
1018123 if(dying)
8829 31552 return Dead(index);
8830
8831
2/2
✓ Branch 0 taken 941601 times.
✓ Branch 1 taken 44970 times.
986571 if(clk==0)
8832 {
8833 44970 removearmos(x,y,ffcactivated);
8834 44970 }
8835
8836
4/4
✓ Branch 0 taken 816947 times.
✓ Branch 1 taken 169624 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 811682 times.
986571 if(clk>=0 && !slide())
8837 {
8838 // switch(d->misc1)
8839
2/2
✓ Branch 0 taken 337868 times.
✓ Branch 1 taken 473814 times.
811682 switch(dmisc1)
8840 {
8841 case 0: //line of sight
8842 case 2:
8843
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124459 times.
✓ Branch 2 taken 49109 times.
✓ Branch 3 taken 35464 times.
✓ Branch 4 taken 15780 times.
✓ Branch 5 taken 101784 times.
✓ Branch 6 taken 4365 times.
✓ Branch 7 taken 6907 times.
337868 switch(misc) //is this leever active
8844 {
8845 case -1: //submerged
8846 {
8847
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124459 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8848
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 114160 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124459 if((dmisc1==2)&&(zc_oldrand()&255))
8849 {
8850 10261 break;
8851 }
8852
8853 114198 int32_t active=0;
8854
8855
2/2
✓ Branch 0 taken 783342 times.
✓ Branch 1 taken 114198 times.
897540 for(int32_t i=0; i<guys.Count(); i++)
8856 {
8857
4/4
✓ Branch 0 taken 627294 times.
✓ Branch 1 taken 156048 times.
✓ Branch 2 taken 401598 times.
✓ Branch 3 taken 225696 times.
783342 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8858 {
8859 225696 ++active;
8860 225696 }
8861 783342 }
8862
8863
2/2
✓ Branch 0 taken 112327 times.
✓ Branch 1 taken 1871 times.
114198 if(active<((dmisc1==2)?1:2))
8864 {
8865 1871 misc=0; //activate this one
8866 1871 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8867 1871 }
8868 }
8869 114198 break;
8870
8871 case 0:
8872 {
8873
8874
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
49109 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8875 {
8876 misc=1;
8877 clk2=0;
8878 }
8879
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 49052 times.
49109 else if (clk3<=0)
8880 {
8881 57 misc = -1;
8882 57 break;
8883 }
8884 49052 int32_t s=0;
8885
8886
2/2
✓ Branch 0 taken 273250 times.
✓ Branch 1 taken 49052 times.
322302 for(int32_t i=0; i<guys.Count(); i++)
8887 {
8888
4/4
✓ Branch 0 taken 164314 times.
✓ Branch 1 taken 108936 times.
✓ Branch 2 taken 156432 times.
✓ Branch 3 taken 7882 times.
273250 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8889 {
8890 7882 ++s;
8891 7882 }
8892 273250 }
8893
8894
2/2
✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 41170 times.
49052 if(s>0)
8895 {
8896 7882 break;
8897 }
8898
8899 41170 int32_t d2=zc_oldrand()&1;
8900
8901
2/2
✓ Branch 0 taken 14509 times.
✓ Branch 1 taken 26661 times.
41170 if(HeroDir()>=left)
8902 {
8903 26661 d2+=2;
8904 26661 }
8905
8906
4/4
✓ Branch 0 taken 39722 times.
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 662 times.
✓ Branch 3 taken 39060 times.
41170 if(canplace(d2) || canplace(d2^1))
8907 {
8908 2110 misc=1;
8909 2110 clk2=0;
8910 2110 clk=0;
8911 2110 }
8912 }
8913 41170 break;
8914
8915 case 1:
8916
8917
7/8
✓ Branch 0 taken 33397 times.
✓ Branch 1 taken 2067 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35464 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
8918
8919 35464 break;
8920
8921 case 2:
8922
8923
7/8
✓ Branch 0 taken 13865 times.
✓ Branch 1 taken 1915 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15780 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
8924
8925 15780 break;
8926
8927 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
8928 case 3:
8929
8930
5/6
✓ Branch 0 taken 98195 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 98195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95468 times.
101784 if(stunclk || frozenclock || watch) break;
8931
8932
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 95326 times.
95468 if(scored) dir^=1;
8933
8934
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 94963 times.
95468 if(!canmove(dir,false)) misc=4;
8935 94963 else move(zslongToFix(dstep*100));
8936
8937 95468 break;
8938
8939 case 4:
8940
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4365 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
8941
2/2
✓ Branch 0 taken 3897 times.
✓ Branch 1 taken 468 times.
4365 if(--clk2<=16)
8942 {
8943 468 misc=5;
8944 468 clk=8;
8945 468 }
8946
8947 4365 break;
8948
8949 case 5:
8950
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6907 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
8951
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 410 times.
6907 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
8952
8953 6907 break;
8954 } // switch(misc)
8955
8956 337868 break;
8957
8958 default: //random
8959 // step=d->misc3/100.0;
8960
8961 473814 step=zslongToFix(dmisc3*100);
8962
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473814 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
8963 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8964 {
8965 if (clk2 < 48) clk2+=2;
8966 if (clk2 >= 300) clk2-=2;
8967 }
8968
8969
2/2
✓ Branch 0 taken 60840 times.
✓ Branch 1 taken 412974 times.
473814 if(clk2<32) misc=1;
8970
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 382730 times.
412974 else if(clk2<48) misc=2;
8971
2/2
✓ Branch 0 taken 289541 times.
✓ Branch 1 taken 93189 times.
382730 else if(clk2<300)
8972 {
8973 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
8974 {
8975 fix_coords();
8976 }*/
8977 289541 misc=3;
8978 289541 step = zslongToFix(dstep*100);
8979 289541 }
8980
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 84180 times.
93189 else if(clk2<316) misc=2;
8981
2/2
✓ Branch 0 taken 43755 times.
✓ Branch 1 taken 40425 times.
84180 else if(clk2<412) misc=1;
8982
2/2
✓ Branch 0 taken 40151 times.
✓ Branch 1 taken 274 times.
40425 else if(clk2<540)
8983 {
8984 40151 misc=0;
8985 40151 step=0;
8986 40151 }
8987 274 else clk2=0;
8988
8989
2/2
✓ Branch 0 taken 471961 times.
✓ Branch 1 taken 1853 times.
473814 if(clk2==48) clk=0;
8990
8991 // variable_walk(d->rate, d->homing, 0);
8992 473814 variable_walk(rate, homing, 0);
8993 473814 } // switch(dmisc1)
8994 811682 }
8995
8996 986571 hxofs=(misc>=2)?0:1000;
8997 986571 return enemy::animate(index);
8998 1018478 }
8999
9000 80892 bool eLeever::canplace(int32_t d2)
9001 {
9002 80892 int32_t nx=HeroX();
9003 80892 int32_t ny=HeroY();
9004
9005
2/2
✓ Branch 0 taken 28492 times.
✓ Branch 1 taken 52400 times.
80892 if(d2<left) ny&=0xF0;
9006 52400 else nx&=0xF0;
9007
9008
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14174 times.
✓ Branch 2 taken 14318 times.
✓ Branch 3 taken 26181 times.
✓ Branch 4 taken 26219 times.
80892 switch(d2)
9009 {
9010 // case up: ny-=((d->misc1==0)?32:48); break;
9011 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
9012 // case left: nx-=((d->misc1==0)?32:48); break;
9013 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
9014 case up:
9015
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 30 times.
14174 ny-=((dmisc1==0||dmisc1==2)?32:48);
9016 14174 break;
9017
9018 case down:
9019
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14284 times.
14318 ny+=((dmisc1==0||dmisc1==2)?32:48);
9020
9021
4/4
✓ Branch 0 taken 10086 times.
✓ Branch 1 taken 4232 times.
✓ Branch 2 taken 10075 times.
✓ Branch 3 taken 11 times.
14318 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9022
9023 14318 break;
9024
9025 case left:
9026
2/2
✓ Branch 0 taken 25528 times.
✓ Branch 1 taken 653 times.
26181 nx-=((dmisc1==0||dmisc1==2)?32:48);
9027 26181 break;
9028
9029 case right:
9030
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25573 times.
26219 nx+=((dmisc1==0||dmisc1==2)?32:48);
9031
9032
4/4
✓ Branch 0 taken 19151 times.
✓ Branch 1 taken 7068 times.
✓ Branch 2 taken 18549 times.
✓ Branch 3 taken 602 times.
26219 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9033
9034 26219 break;
9035 }
9036
9037
4/4
✓ Branch 0 taken 20428 times.
✓ Branch 1 taken 60464 times.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 11427 times.
80892 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9038 69465 return false;
9039
9040
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 10563 times.
11427 if(d2>=left)
9041
4/4
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 5538 times.
✓ Branch 2 taken 9317 times.
✓ Branch 3 taken 1246 times.
10563 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9042 9317 return false;
9043
9044 2110 x=nx;
9045 2110 y=ny;
9046 2110 dir=d2^1;
9047 2110 return true;
9048 80892 }
9049
9050 1024382 void eLeever::draw(BITMAP *dest)
9051 {
9052 // cs=d->cset;
9053 1024382 cs=dcset;
9054 1024382 update_enemy_frame();
9055
3/4
✓ Branch 0 taken 1024027 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024027 times.
1024382 if(!fallclk&&!drownclk)
9056 {
9057
2/2
✓ Branch 0 taken 637088 times.
✓ Branch 1 taken 386939 times.
1024027 switch(misc)
9058 {
9059 case -1:
9060 case 0:
9061 386939 return;
9062 }
9063 637088 }
9064
9065 637443 enemy::draw(dest);
9066 1024382 }
9067
9068 998 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9069 998 {
9070 998 hashero=false;
9071 //nets+1000;
9072
1/4
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
998 if (SIZEflags != 0) init_size_flags();;
9073 998 }
9074
9075 504762 bool eWallM::animate(int32_t index)
9076 {
9077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504762 times.
504762 if(switch_hooked) return enemy::animate(index);
9078
2/4
✓ Branch 0 taken 504762 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 504762 times.
504762 if(fallclk||drownclk)
9079 {
9080 return enemy::animate(index);
9081 }
9082
2/2
✓ Branch 0 taken 9856 times.
✓ Branch 1 taken 494906 times.
504762 if(dying)
9083 9856 return Dead(index);
9084
9085
2/2
✓ Branch 0 taken 463930 times.
✓ Branch 1 taken 30976 times.
494906 if(clk==0)
9086 {
9087 30976 removearmos(x,y,ffcactivated);
9088 30976 }
9089
9090 494906 hxofs=1000;
9091
2/2
✓ Branch 0 taken 117732 times.
✓ Branch 1 taken 377174 times.
494906 if(misc==0) //inside wall, ready to spawn?
9092 {
9093
4/4
✓ Branch 0 taken 228512 times.
✓ Branch 1 taken 148662 times.
✓ Branch 2 taken 16723 times.
✓ Branch 3 taken 211789 times.
377174 if(frame-wallm_load_clk>80 && clk>=0)
9094 {
9095 211789 int32_t wall=hero_on_wall();
9096 211789 int32_t wallm_cnt=0;
9097
9098
2/2
✓ Branch 0 taken 1670618 times.
✓ Branch 1 taken 211789 times.
1882407 for(int32_t i=0; i<guys.Count(); i++)
9099
2/2
✓ Branch 0 taken 657527 times.
✓ Branch 1 taken 1013091 times.
2683709 if(((enemy*)guys.spr(i))->family==eeWALLM)
9100 {
9101 1013091 int32_t m=((enemy*)guys.spr(i))->misc;
9102
9103
4/4
✓ Branch 0 taken 50104 times.
✓ Branch 1 taken 962987 times.
✓ Branch 2 taken 36738 times.
✓ Branch 3 taken 13366 times.
1013091 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9104 {
9105 13366 ++wallm_cnt;
9106 13366 }
9107 1013091 }
9108
9109
2/2
✓ Branch 0 taken 210948 times.
✓ Branch 1 taken 841 times.
211789 if(wall>0)
9110 {
9111 841 --wall;
9112 841 misc=1; //emerging from the wall?
9113 841 clk2=0;
9114 841 clk3=wall^1;
9115 841 wallm_load_clk=frame;
9116
9117
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 327 times.
841 if(wall<=down)
9118 {
9119
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 423 times.
514 if(HeroDir()==left)
9120 91 dir=right;
9121 else
9122 423 dir=left;
9123 514 }
9124 else
9125 {
9126
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 261 times.
327 if(HeroDir()==up)
9127 66 dir=down;
9128 else
9129 261 dir=up;
9130 }
9131
9132
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 223 times.
✓ Branch 4 taken 104 times.
841 switch(wall)
9133 {
9134 case up:
9135 231 y=0;
9136 231 break;
9137
9138 case down:
9139 283 y=160;
9140 283 break;
9141
9142 case left:
9143 223 x=0;
9144 223 break;
9145
9146 case right:
9147 104 x=240;
9148 104 break;
9149 }
9150
9151
9152
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 91 times.
841 switch(dir)
9153 {
9154 case up:
9155 261 y=(HeroY()+48-(wallm_cnt&1)*12);
9156 261 flip=wall&1;
9157 261 break;
9158
9159 case down:
9160 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9161 66 flip=((wall&1)^1)+2;
9162 66 break;
9163
9164 case left:
9165 423 x=(HeroX()+48-(wallm_cnt&1)*12);
9166 423 flip=(wall==up?2:0)+1;
9167 423 break;
9168
9169 case right:
9170 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9171 91 flip=(wall==up?2:0);
9172 91 break;
9173 }
9174
9175 841 }
9176 211789 }
9177 377174 }
9178 else
9179 117732 wallm_crawl();
9180
9181 494906 return enemy::animate(index);
9182 504762 }
9183
9184 117732 void eWallM::wallm_crawl()
9185 {
9186 117732 bool w=watch;
9187 117732 hxofs=0;
9188
9189
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 116922 times.
117732 if(slide())
9190 {
9191 810 return;
9192 }
9193
9194 // if(dying || watch || (!hashero && stunclk))
9195
6/8
✓ Branch 0 taken 116922 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115593 times.
✓ Branch 3 taken 1329 times.
✓ Branch 4 taken 101047 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 101047 times.
116922 if(dying || (!hashero && ( stunclk || frozenclock )))
9196 {
9197 14546 return;
9198 }
9199
9200 102376 watch=false;
9201 102376 ++clk2;
9202 // Misc1: slightly different movement
9203 102376 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9204
9205 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102376 times.
102376 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9207
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 96159 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
102376 if(w&&misc>=3&&misc<=5)
9208 {
9209 4491 --clk2;
9210 4491 }
9211
9212
4/4
✓ Branch 0 taken 39396 times.
✓ Branch 1 taken 52852 times.
✓ Branch 2 taken 9984 times.
✓ Branch 3 taken 144 times.
102376 switch(misc)
9213 {
9214 case 1:
9215 case 2:
9216 52852 zc_swap(dir,clk3);
9217 52852 move(step);
9218 52852 zc_swap(dir,clk3);
9219 52852 break;
9220
9221 case 3:
9222 case 4:
9223 case 5:
9224
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 34905 times.
39396 if(w)
9225 {
9226 4491 watch=w;
9227 4491 return;
9228 }
9229
9230 34905 move(step);
9231 34905 break;
9232
9233 case 6:
9234 case 7:
9235 9984 zc_swap(dir,clk3);
9236 9984 dir^=1;
9237 9984 move(step);
9238 9984 dir^=1;
9239 9984 zc_swap(dir,clk3);
9240 9984 break;
9241
9242 default:
9243 144 misc=0;
9244 144 break;
9245 }
9246
9247 97885 watch=w;
9248 117732 }
9249
9250 9 void eWallM::grabhero()
9251 {
9252 9 hashero=true;
9253 9 superman=1;
9254 9 }
9255
9256 507147 void eWallM::draw(BITMAP *dest)
9257 {
9258 507147 dummy_bool[1]=hashero;
9259 507147 update_enemy_frame();
9260
9261
4/6
✓ Branch 0 taken 377966 times.
✓ Branch 1 taken 129181 times.
✓ Branch 2 taken 377966 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 377966 times.
507147 if(misc>0 || fallclk||drownclk)
9262 {
9263 129181 masked_draw(dest,16,playing_field_offset+16,224,144);
9264 129181 }
9265
9266 // enemy::draw(dest);
9267 // tile = clk&8 ? 128:129;
9268 507147 }
9269
9270 bool eWallM::isSubmerged() const
9271 {
9272 return ( !misc );
9273 }
9274
9275 1600 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9276 1600 {
9277
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 ox=x; //original x
9278
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 oy=y; //original y
9279
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 126 times.
1600 if(get_qr(qr_TRAPPOSFIX))
9280 {
9281
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9282 126 }
9283
9284 1600 mainguy=false;
9285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
1600 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9286 //nets+420;
9287 1600 dummy_int[1]=0;
9288
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1600 if (SIZEflags != 0) init_size_flags();;
9289 1600 }
9290
9291 1036935 bool eTrap::animate(int32_t index)
9292 {
9293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1036935 times.
1036935 if(switch_hooked) return enemy::animate(index);
9294
2/4
✓ Branch 0 taken 1036935 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1036935 times.
1036935 if(fallclk||drownclk) return enemy::animate(index);
9295
2/2
✓ Branch 0 taken 1015341 times.
✓ Branch 1 taken 21594 times.
1036935 if(clk<0)
9296 21594 return enemy::animate(index);
9297
9298
2/2
✓ Branch 0 taken 951124 times.
✓ Branch 1 taken 64217 times.
1015341 if(clk==0)
9299 {
9300 64217 removearmos(x,y,ffcactivated);
9301 64217 }
9302
9303
2/2
✓ Branch 0 taken 317997 times.
✓ Branch 1 taken 697344 times.
1015341 if(misc==0) // waiting
9304 {
9305 697344 ox = x;
9306 697344 oy = y;
9307 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9308 697344 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9309
9310
4/4
✓ Branch 0 taken 240663 times.
✓ Branch 1 taken 456681 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 107487 times.
697344 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9311 {
9312 107487 dir=down;
9313 107487 }
9314
4/4
✓ Branch 0 taken 391518 times.
✓ Branch 1 taken 198339 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 258342 times.
589857 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9315 {
9316 258342 dir=right;
9317 258342 }
9318
4/4
✓ Branch 0 taken 210645 times.
✓ Branch 1 taken 120870 times.
✓ Branch 2 taken 133176 times.
✓ Branch 3 taken 77469 times.
331515 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9319 {
9320 77469 dir=up;
9321 77469 }
9322 else
9323 {
9324 254046 dir=left;
9325 }
9326
9327 697344 int32_t d2=lined_up(15,true);
9328
9329
4/4
✓ Branch 0 taken 267045 times.
✓ Branch 1 taken 430299 times.
✓ Branch 2 taken 1111152 times.
✓ Branch 3 taken 413808 times.
1091329 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9330
2/2
✓ Branch 0 taken 232556 times.
✓ Branch 1 taken 190596 times.
413808 ((d2>down) && (dmisc1==2)) ||
9331
2/2
✓ Branch 0 taken 187069 times.
✓ Branch 1 taken 60611 times.
190596 ((d2>right) && (!dmisc1)) ||
9332
2/2
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 146305 times.
247680 ((d2<l_up) && (dmisc1==4)) ||
9333
3/4
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 247680 times.
✓ Branch 2 taken 393985 times.
✗ Branch 3 not taken.
146305 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9334
3/4
✓ Branch 0 taken 393985 times.
✓ Branch 1 taken 146305 times.
✓ Branch 2 taken 393985 times.
✗ Branch 3 not taken.
247680 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9335 {
9336 2525663 d2=-1;
9337 2525663 }
9338
9339
4/4
✓ Branch 0 taken 20700 times.
✓ Branch 1 taken 428964 times.
✓ Branch 2 taken 18593 times.
✓ Branch 3 taken 2107 times.
449664 if(d2!=-1 && trapmove(d2))
9340 {
9341 2107 dir=d2;
9342 2107 misc=1;
9343 2107 clk2=(dir==down)?3:0;
9344 2107 }
9345 449664 }
9346
9347
2/2
✓ Branch 0 taken 678404 times.
✓ Branch 1 taken 89257 times.
767661 if(misc==1) // charging
9348 {
9349 89257 clk2=(clk2+1)&3;
9350 89257 step=(clk2==3)?1:2;
9351
9352
4/4
✓ Branch 0 taken 88461 times.
✓ Branch 1 taken 796 times.
✓ Branch 2 taken 1105 times.
✓ Branch 3 taken 87356 times.
89257 if(!trapmove(dir) || clip())
9353 {
9354 1901 misc=2;
9355
9356
1/2
✓ Branch 0 taken 1901 times.
✗ Branch 1 not taken.
1901 if(dir<l_up)
9357 {
9358 1901 dir=dir^1;
9359 1901 }
9360 else
9361 {
9362 dir=dir^3;
9363 }
9364 1901 }
9365 else
9366 {
9367 87356 sprite::move(step);
9368 }
9369 89257 }
9370
9371
2/2
✓ Branch 0 taken 534913 times.
✓ Branch 1 taken 232748 times.
767661 if(misc==2) // retreating
9372 {
9373 232748 step=(++clk2&1)?1:0;
9374
9375
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 39011 times.
✓ Branch 2 taken 80505 times.
✓ Branch 3 taken 29129 times.
✓ Branch 4 taken 84103 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
232748 switch(dir)
9376 {
9377 case up:
9378
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 38739 times.
39011 if(int32_t(y)<=oy) goto trap_rest;
9379 38739 else sprite::move(step);
9380
9381 38739 break;
9382
9383 case left:
9384
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 80117 times.
80505 if(int32_t(x)<=ox) goto trap_rest;
9385 80117 else sprite::move(step);
9386
9387 80117 break;
9388
9389 case down:
9390
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 28905 times.
29129 if(int32_t(y)>=oy) goto trap_rest;
9391 28905 else sprite::move(step);
9392
9393 28905 break;
9394
9395 case right:
9396
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 83672 times.
84103 if(int32_t(x)>=ox) goto trap_rest;
9397 83672 else sprite::move(step);
9398
9399 83672 break;
9400
9401 case l_up:
9402 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9403 else sprite::move(step);
9404
9405 break;
9406
9407 case r_up:
9408 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9409 else sprite::move(step);
9410
9411 break;
9412
9413 case l_down:
9414 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9415 else sprite::move(step);
9416
9417 break;
9418
9419 case r_down:
9420 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9421 else sprite::move(step);
9422
9423 break;
9424 trap_rest:
9425 {
9426 1315 x=ox;
9427 1315 y=oy;
9428 1315 misc=0;
9429 }
9430 1315 }
9431 232748 }
9432
9433 767661 return enemy::animate(index);
9434 789255 }
9435
9436 109957 bool eTrap::trapmove(int32_t ndir)
9437 {
9438
2/2
✓ Branch 0 taken 80193 times.
✓ Branch 1 taken 29764 times.
109957 if(get_qr(qr_MEANTRAPS))
9439 {
9440
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 78853 times.
80193 if(tmpscr->flags2&fFLOATTRAPS)
9441 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9442
9443 78853 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9444 }
9445
9446
6/6
✓ Branch 0 taken 14672 times.
✓ Branch 1 taken 15092 times.
✓ Branch 2 taken 7198 times.
✓ Branch 3 taken 7474 times.
✓ Branch 4 taken 2468 times.
✓ Branch 5 taken 4730 times.
29764 if(oy==80 && !(ndir==left || ndir == right))
9447 4730 return false;
9448
9449
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25034 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25034 if(ox==128 && !(ndir==up || ndir==down))
9450 return false;
9451
9452
3/4
✓ Branch 0 taken 7496 times.
✓ Branch 1 taken 17538 times.
✓ Branch 2 taken 7496 times.
✗ Branch 3 not taken.
25034 if(oy<80 && ndir==up)
9453 return false;
9454
9455
3/4
✓ Branch 0 taken 7596 times.
✓ Branch 1 taken 17438 times.
✓ Branch 2 taken 7596 times.
✗ Branch 3 not taken.
25034 if(oy>80 && ndir==down)
9456 return false;
9457
9458
4/4
✓ Branch 0 taken 14455 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 9733 times.
✓ Branch 3 taken 4722 times.
25034 if(ox<128 && ndir==left)
9459 4722 return false;
9460
9461
4/4
✓ Branch 0 taken 10579 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 9866 times.
✓ Branch 3 taken 713 times.
20312 if(ox>128 && ndir==right)
9462 713 return false;
9463
9464
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 4067 times.
✓ Branch 3 taken 5666 times.
✓ Branch 4 taken 4067 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy<80 && ndir==l_up)
9465 return false;
9466
9467
5/6
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 3911 times.
✓ Branch 3 taken 5822 times.
✓ Branch 4 taken 3911 times.
✗ Branch 5 not taken.
19599 if(ox<128 && oy>80 && ndir==l_down)
9468 return false;
9469
9470
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3429 times.
✓ Branch 3 taken 6437 times.
✓ Branch 4 taken 3429 times.
✗ Branch 5 not taken.
19599 if(ox>128 && oy<80 && ndir==r_up)
9471 return false;
9472
9473
5/6
✓ Branch 0 taken 9866 times.
✓ Branch 1 taken 9733 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 6181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3685 times.
19599 if(ox>128 && oy>80 && ndir==r_down)
9474 return false;
9475
9476 19599 return true;
9477 109957 }
9478
9479 88461 bool eTrap::clip()
9480 {
9481
2/2
✓ Branch 0 taken 43022 times.
✓ Branch 1 taken 45439 times.
88461 if(get_qr(qr_MEANPLACEDTRAPS))
9482 {
9483
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
✓ Branch 2 taken 8656 times.
✓ Branch 3 taken 15895 times.
✓ Branch 4 taken 15096 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45439 switch(dir)
9484 {
9485 case up:
9486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
5792 if(y<=0) return true;
9487
9488 5792 break;
9489
9490 case down:
9491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8656 times.
8656 if(y>=160) return true;
9492
9493 8656 break;
9494
9495 case left:
9496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15895 times.
15895 if(x<=0) return true;
9497
9498 15895 break;
9499
9500 case right:
9501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15096 times.
15096 if(x>=240) return true;
9502
9503 15096 break;
9504
9505 case l_up:
9506 if(y<=0||x<=0) return true;
9507
9508 break;
9509
9510 case l_down:
9511 if(y>=160||x<=0) return true;
9512
9513 break;
9514
9515 case r_up:
9516 if(y<=0||x>=240) return true;
9517
9518 break;
9519
9520 case r_down:
9521 if(y>=160||x>=240) return true;
9522
9523 break;
9524 }
9525
9526 45439 return false;
9527 }
9528 else
9529 {
9530
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4882 times.
✓ Branch 2 taken 5449 times.
✓ Branch 3 taken 16755 times.
✓ Branch 4 taken 15936 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
43022 switch(dir)
9531 {
9532 case up:
9533
4/4
✓ Branch 0 taken 4828 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4641 times.
✓ Branch 3 taken 187 times.
4882 if(oy>80 && y<=86) return true;
9534
9535 4695 break;
9536
9537 case down:
9538
4/4
✓ Branch 0 taken 5368 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5172 times.
✓ Branch 3 taken 196 times.
5449 if(oy<80 && y>=80) return true;
9539
9540 5253 break;
9541
9542 case left:
9543
4/4
✓ Branch 0 taken 16665 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 16286 times.
✓ Branch 3 taken 379 times.
16755 if(ox>128 && x<=124) return true;
9544
9545 16376 break;
9546
9547 case right:
9548
4/4
✓ Branch 0 taken 15855 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 15512 times.
✓ Branch 3 taken 343 times.
15936 if(ox<120 && x>=116) return true;
9549
9550 15593 break;
9551
9552 case l_up:
9553 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9554
9555 break;
9556
9557 case l_down:
9558 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9559
9560 break;
9561
9562 case r_up:
9563 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9564
9565 break;
9566
9567 case r_down:
9568 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9569
9570 break;
9571 }
9572
9573 41917 return false;
9574 }
9575 88461 }
9576
9577 1043991 void eTrap::draw(BITMAP *dest)
9578 {
9579 1043991 update_enemy_frame();
9580 1043991 enemy::draw(dest);
9581 1043991 }
9582
9583 5705 int32_t eTrap::takehit(weapon*,weapon*)
9584 {
9585 5705 return 0;
9586 }
9587
9588 832 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9589 832 {
9590 832 lasthit=-1;
9591 832 lasthitclk=0;
9592 832 mainguy=false;
9593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9594
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 step=2;
9595
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9596 {
9597
2/4
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
399 dir=(x<=112)?right:left;
9598 399 }
9599 else
9600 {
9601
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9602 }
9603
9604
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 72 times.
832 if(get_qr(qr_TRAPPOSFIX))
9605 {
9606
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9607 72 }
9608
9609 //nets+((id==eTRAP_LR)?540:520);
9610 832 dummy_int[1]=0;
9611
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if (SIZEflags != 0) init_size_flags();;
9612 832 }
9613
9614 346559 bool eTrap2::animate(int32_t index)
9615 {
9616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346559 times.
346559 if(switch_hooked) return enemy::animate(index);
9617
2/4
✓ Branch 0 taken 346559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346559 times.
346559 if(fallclk||drownclk) return enemy::animate(index);
9618
2/2
✓ Branch 0 taken 335533 times.
✓ Branch 1 taken 11026 times.
346559 if(clk<0)
9619 11026 return enemy::animate(index);
9620
9621
2/2
✓ Branch 0 taken 21385 times.
✓ Branch 1 taken 314148 times.
335533 if(clk==0)
9622 {
9623 21385 removearmos(x,y,ffcactivated);
9624 21385 }
9625
9626
2/2
✓ Branch 0 taken 211207 times.
✓ Branch 1 taken 124326 times.
335533 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9627 {
9628
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9629 {
9630 11074 --lasthitclk;
9631 11074 }
9632 else
9633 {
9634 113252 lasthit=-1;
9635 }
9636
9637 124326 bool hitenemy=false;
9638
9639
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9640 {
9641
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9642 {
9643
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9644 {
9645 3669 lasthit=j;
9646 3669 lasthitclk=10;
9647 3669 hitenemy=true;
9648 3669 guys.spr(j)->lasthit=index;
9649 3669 guys.spr(j)->lasthitclk=10;
9650 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9651 3669 }
9652 730351 }
9653 864860 }
9654
9655
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9656 {
9657
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9658 {
9659 3155 lasthit=-1;
9660 3155 lasthitclk=0;
9661 3155 }
9662
9663
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9664 362 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9665
9666 5986 dir=dir^1;
9667 5986 }
9668
9669 124326 sprite::move(step);
9670 124326 }
9671 else
9672 {
9673
3/4
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 6919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204288 times.
211207 if(!trapmove(dir) || clip())
9674 {
9675
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 1521 times.
6919 if(get_qr(qr_MORESOUNDS))
9676 1521 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9677
9678 6919 dir=dir^1;
9679 6919 }
9680
9681 211207 sprite::move(step);
9682 }
9683
9684 335533 return enemy::animate(index);
9685 346559 }
9686
9687 341519 bool eTrap2::trapmove(int32_t ndir)
9688 {
9689
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339641 times.
341519 if(tmpscr->flags2&fFLOATTRAPS)
9690 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9691
9692 339641 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9693 341519 }
9694
9695 328290 bool eTrap2::clip()
9696 {
9697
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75153 times.
✓ Branch 4 taken 75788 times.
328290 switch(dir)
9698 {
9699 case up:
9700
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9701
9702 88320 break;
9703
9704 case down:
9705
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=160) return true;
9706
9707 89029 break;
9708
9709 case left:
9710
1/2
✓ Branch 0 taken 75153 times.
✗ Branch 1 not taken.
75153 if(x<=0) return true;
9711
9712 75153 break;
9713
9714 case right:
9715
1/2
✓ Branch 0 taken 75788 times.
✗ Branch 1 not taken.
75788 if(x>=240) return true;
9716
9717 75788 break;
9718 }
9719
9720 328290 return false;
9721 328290 }
9722
9723 350933 void eTrap2::draw(BITMAP *dest)
9724 {
9725 350933 update_enemy_frame();
9726 350933 enemy::draw(dest);
9727 350933 }
9728
9729 3169 int32_t eTrap2::takehit(weapon*,weapon*)
9730 {
9731 3169 return 0;
9732 }
9733
9734 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9735 354 {
9736 //do not show "enemy appering" anim -DD
9737 354 clk=0;
9738 354 mainguy=false;
9739 354 clk2=-14;
9740 //Enemy Editor Size Tab
9741
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9742 //nets+1640;
9743 354 }
9744
9745 354 void eRock::init_size_flags()
9746 {
9747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9748 354 else hxofs = -2;
9749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9750 354 else hyofs = -2;
9751
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9752 354 else hit_width = 20;
9753
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9754 354 else hit_height = 20;
9755
9756
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9757
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9758
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9759
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & guyflagOVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9760
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & guyflagOVERRIDE_DRAW_Y_OFFSET) != 0)
9761 {
9762 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9763 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9764 }
9765
9766
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & guyflagOVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9767 354 }
9768
9769 121997 bool eRock::animate(int32_t index)
9770 {
9771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9772
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9774 return Dead(index);
9775
9776
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9777 {
9778 8376 removearmos(x,y,ffcactivated);
9779 8376 }
9780
9781
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9782 {
9783 697 x=zc_oldrand()&0xF0;
9784 697 y=0;
9785 697 clk3=0;
9786 697 clk2=zc_oldrand()&15;
9787 697 }
9788
9789
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9790 {
9791
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9792 {
9793 3430 dir=zc_oldrand()&1;
9794
9795
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9796
9797
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9798 3430 }
9799
9800
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9801 {
9802 95993 x += dir ? 1 : -1; //right, left
9803 95993 dummy_int[1]=dir;
9804
9805
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9806 {
9807 6852 y-=2; //up
9808 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9809 6852 }
9810
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9811 {
9812 10208 y--; //up
9813 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9814 10208 }
9815
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9816 {
9817 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9818 10135 }
9819
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9820 {
9821 10058 y++; //down
9822 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9823 10058 }
9824 else
9825 {
9826 58740 y+=2; //down
9827 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9828 }
9829
9830 95993 ++clk3;
9831 95993 }
9832
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<176)
9833 2761 clk3=0; // next bounce
9834 else
9835 423 clk2 = -(zc_oldrand()&63); // back to top
9836 99177 }
9837
9838 121997 return enemy::animate(index);
9839 121997 }
9840
9841 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9842 {
9843
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(clk2>=0)
9844 {
9845 44250 int32_t tempy=yofs;
9846 44250 flip = 0;
9847 44250 int32_t fdiv = frate/4;
9848
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9849
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9850 44250 efrate:((clk>=(frate>>1))?1:0);
9851 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9852
9853 44250 yofs+=8;
9854
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44250 times.
44250 if(!shadow_overpit(this))
9856 44250 sprite::drawshadow(dest, translucent);
9857 44250 yofs=tempy;
9858 44250 }
9859 51441 }
9860
9861 122078 void eRock::draw(BITMAP *dest)
9862 {
9863
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9864 {
9865 105043 int32_t tempdir=dir;
9866 105043 dir=dummy_int[2];
9867 105043 update_enemy_frame();
9868 105043 enemy::draw(dest);
9869 105043 dir=tempdir;
9870 105043 }
9871 122078 }
9872
9873 1014 int32_t eRock::takehit(weapon*,weapon*)
9874 {
9875 1014 return 0;
9876 }
9877
9878 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9879 30 {
9880 30 clk=0;
9881 30 mainguy=false;
9882 30 clk2=-14;
9883
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9884 //nets+1680;
9885 30 }
9886
9887 4440 bool eBoulder::animate(int32_t index)
9888 {
9889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9890
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9892 return Dead(index);
9893
9894
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9895 {
9896 290 removearmos(x,y,ffcactivated);
9897 290 }
9898
9899 zfix *vert;
9900
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9901
9902
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
9903 {
9904 32 x=zc_oldrand()&0xF0;
9905 32 y=-32;
9906 32 clk3=0;
9907 32 clk2=zc_oldrand()&15;
9908 32 }
9909
9910
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
9911 {
9912
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
9913 {
9914 131 dir=zc_oldrand()&1;
9915
9916
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
9917
9918
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
9919 131 }
9920
9921
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
9922 {
9923 3487 x += dir ? 1 : -1; //right, left
9924 3487 dummy_int[1]=dir;
9925
9926
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
9927 {
9928 261 y-=2; //up
9929 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9930 261 }
9931
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
9932 {
9933 382 y--; //up
9934 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9935 382 }
9936
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
9937 {
9938 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
9939 376 }
9940
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
9941 {
9942 367 y++; //down
9943 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9944 367 }
9945 else
9946 {
9947 2101 y+=2; //down
9948 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9949 }
9950
9951 3487 ++clk3;
9952 3487 }
9953
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
9954 101 clk3=0; // next bounce
9955 else
9956 10 clk2 = -(zc_oldrand()&63); // back to top
9957 3598 }
9958
9959 4440 return enemy::animate(index);
9960 4440 }
9961
9962 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
9963 {
9964
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
9965 {
9966 3868 int32_t tempy=yofs;
9967 3868 flip = 0;
9968 3868 int32_t f2=((clk<<2)/frate)<<1;
9969 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9970
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9971
9972 3868 yofs+=8;
9973 3868 xofs-=8;
9974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
9975 3868 sprite::drawshadow(dest, translucent);
9976 3868 xofs+=16;
9977 3868 ++shadowtile;
9978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
9979 3868 sprite::drawshadow(dest, translucent);
9980 3868 yofs+=16;
9981 3868 shadowtile+=20;
9982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
9983 3868 sprite::drawshadow(dest, translucent);
9984 3868 xofs-=16;
9985 3868 --shadowtile;
9986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
9987 3868 sprite::drawshadow(dest, translucent);
9988 3868 xofs+=8;
9989 3868 yofs=tempy;
9990 3868 }
9991 4440 }
9992
9993 4440 void eBoulder::draw(BITMAP *dest)
9994 {
9995
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
9996 {
9997 3868 int32_t tempdir=dir;
9998 3868 dir=dummy_int[2];
9999 3868 update_enemy_frame();
10000 3868 dir=tempdir;
10001 3868 xofs-=8;
10002 3868 yofs-=8;
10003 3868 drawblock(dest,15);
10004 3868 xofs+=8;
10005 3868 yofs+=8;
10006 // enemy::draw(dest);
10007 3868 }
10008 4440 }
10009
10010 30 void eBoulder::init_size_flags()
10011 {
10012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10013 30 else hxofs = -10;
10014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10015 30 else hyofs = -10;
10016
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10017 30 else hit_width = 36;
10018
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10019 30 else hit_height = 36;
10020
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10021 30 else hzsz = 16; //can't be jumped
10022
10023
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10024
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10025
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10026
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & guyflagOVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10027
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & guyflagOVERRIDE_DRAW_Y_OFFSET) != 0)
10028 {
10029 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10030 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10031 }
10032
10033
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & guyflagOVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10034 30 }
10035
10036 int32_t eBoulder::takehit(weapon*,weapon*)
10037 {
10038 return 0;
10039 }
10040
10041 4429 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10042
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3898 times.
4429 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10043 4429 {
10044 /* fixing
10045 hp=1;
10046 */
10047 4429 mainguy=false;
10048
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4422 times.
4429 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10049 4429 hclk=clk; // the "no fire" range
10050 4429 clk=0;
10051 4429 clk3=96;
10052 4429 timer=0;
10053
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4415 times.
4429 if(o_tile==0)
10054 {
10055 4415 superman=1;
10056 4415 hxofs=1000;
10057 4415 }
10058
1/4
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if (SIZEflags != 0) init_size_flags();;
10059 4429 }
10060
10061 2504746 bool eProjectile::animate(int32_t index)
10062 {
10063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504746 times.
2504746 if(switch_hooked) return enemy::animate(index);
10064
2/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2504746 times.
2504746 if(fallclk||drownclk) return enemy::animate(index);
10065
2/2
✓ Branch 0 taken 2492420 times.
✓ Branch 1 taken 12326 times.
2504746 if(clk==0)
10066 {
10067 12326 removearmos(x,y,ffcactivated);
10068 12326 }
10069
10070 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10071 2504746 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10072
10073
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669138 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2504746 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10074 {
10075 403631 dir=down;
10076 403631 }
10077
4/4
✓ Branch 0 taken 1348897 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 916920 times.
2101115 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10078 {
10079 916920 dir=right;
10080 916920 }
10081
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10082 {
10083 358900 dir=up;
10084 358900 }
10085 else
10086 {
10087 825295 dir=left;
10088 }
10089
10090
3/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306267 times.
✓ Branch 3 taken 1198479 times.
2504746 if(!stunclk && ++clk3>80)
10091 {
10092
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197433 times.
1198479 if(dmisc1==9) // Breath type
10093 {
10094
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10095 {
10096 563 unsigned r=zc_oldrand();
10097
10098
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10099 {
10100 6 timer=zc_oldrand()%50+50;
10101 6 }
10102 563 }
10103
10104
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10105 {
10106
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10107 {
10108 119 FireBreath(false);
10109 119 }
10110
10111
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10112 {
10113 6 clk3=0;
10114 6 }
10115 489 }
10116 1046 }
10117
10118 else // Not breath type
10119 {
10120 1197433 unsigned r=zc_oldrand();
10121
10122
4/4
✓ Branch 0 taken 18808 times.
✓ Branch 1 taken 1178625 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17542 times.
1197433 if(!(r&63) && !HeroInRange(minRange))
10123 {
10124 17542 FireWeapon();
10125
10126
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17794 if(get_qr(qr_BROKENSTATUES)==0 &&
10127
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10128 {
10129
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10130 {
10131 909 x-=4;
10132 909 FireWeapon();
10133 909 x+=4;
10134 909 }
10135 14854 }
10136
10137 17542 clk3=0;
10138 17542 }
10139 }
10140 1198479 }
10141
10142 2504746 return enemy::animate(index);
10143 2504746 }
10144
10145 2520335 void eProjectile::draw(BITMAP *dest)
10146 {
10147 2520335 update_enemy_frame();
10148 2520335 enemy::draw(dest);
10149 2520335 }
10150
10151 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10152 533 {
10153 533 hxofs=1000;
10154 533 }
10155
10156 249811 void eTrigger::draw(BITMAP *dest)
10157 {
10158 249811 update_enemy_frame();
10159 249811 enemy::draw(dest);
10160 249811 }
10161
10162 void eTrigger::death_sfx()
10163 {
10164 //silent death
10165 }
10166
10167 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10168 5 {
10169 5 o_tile+=wpnsbuf[iwNPCs].tile;
10170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10171 5 SIZEflags = d->SIZEflags;
10172
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10173 5 }
10174
10175 75 bool eNPC::animate(int32_t index)
10176 {
10177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10178
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10179 70 return Dead(index);
10180
10181
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10182 {
10183 removearmos(x,y,ffcactivated);
10184 }
10185
10186
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10187 {
10188 case 0:
10189 {
10190 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10191 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10192
10193
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10194 {
10195 dir=down;
10196 }
10197
10198
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10199 {
10200 5 dir=right;
10201 5 }
10202 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10203 {
10204 dir=up;
10205 }
10206 else
10207 {
10208 dir=left;
10209 }
10210 }
10211 5 break;
10212
10213 case 1:
10214 halting_walk(rate, homing, 0, hrate, 48);
10215
10216 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10217 {
10218 newdir(rate, homing, 0);
10219 clk2=48;
10220 ++misc;
10221 }
10222
10223 if(clk2==0)
10224 misc=0;
10225
10226 break;
10227 }
10228
10229 5 return enemy::animate(index);
10230 75 }
10231
10232 75 void eNPC::draw(BITMAP *dest)
10233 {
10234 75 update_enemy_frame();
10235 75 enemy::draw(dest);
10236 75 }
10237
10238 int32_t eNPC::takehit(weapon*,weapon*)
10239 {
10240 return 0;
10241 }
10242
10243 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10244 94 {
10245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10246 {
10247 94 o_tile=clk;
10248 94 cs=id>>12;
10249 94 }
10250
10251 94 id=id&0xFFF;
10252 94 clk=0;
10253
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10254 94 mainguy=false;
10255 94 SIZEflags = d->SIZEflags;
10256
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10257 94 }
10258
10259 81 void eSpinTile::facehero()
10260 {
10261
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10262 {
10263
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10264 1 dir = up;
10265 else
10266 dir = down;
10267 1 }
10268 else
10269 {
10270 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10271 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10272
10273
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10274 {
10275 12 dir=l_down;
10276 12 }
10277
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10278 {
10279 1 dir=down;
10280 1 }
10281
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10282 {
10283 12 dir=r_down;
10284 12 }
10285
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10286 {
10287 6 dir=right;
10288 6 }
10289
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10290 {
10291 17 dir=r_up;
10292 17 }
10293
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10294 {
10295 8 dir=up;
10296 8 }
10297
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10298 {
10299 6 dir=l_up;
10300 6 }
10301 else
10302 {
10303 18 dir=left;
10304 }
10305 }
10306 81 }
10307
10308
10309 15539 bool eSpinTile::animate(int32_t index)
10310 {
10311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10312
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10313
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10314 {
10315 1152 return Dead(index);
10316 }
10317
10318
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10319 {
10320 1241 removearmos(x,y,ffcactivated);
10321 1241 }
10322
10323 14387 ++misc;
10324
10325
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10326 {
10327 81 facehero();
10328 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10329 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10330 81 angular=true;
10331 81 angle=ddir;
10332 81 step=zslongToFix(dstep*100);
10333 81 }
10334
10335
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10336 52 kickbucket();
10337
10338 14387 sprite::move(step);
10339 14387 return enemy::animate(index);
10340 15539 }
10341
10342 15457 void eSpinTile::draw(BITMAP *dest)
10343 {
10344 15457 update_enemy_frame();
10345 15457 y-=(misc>>4);
10346 15457 yofs+=2;
10347 15457 enemy::draw(dest);
10348 15457 yofs-=2;
10349 15457 y+=(misc>>4);
10350 15457 }
10351
10352 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10353 {
10354 15457 flip = 0;
10355 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10356 15457 yofs+=4;
10357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10358 15457 enemy::drawshadow(dest, translucent);
10359 15457 yofs-=4;
10360 15457 }
10361
10362 2765 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10363 2765 {
10364 //these are here to bypass compiler warnings about unused arguments
10365 2765 Clk=Clk;
10366 2765 mainguy=false;
10367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2765 times.
2765 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10368 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
10369 {
10370 clk=1;
10371 }*/
10372 //nets+880;
10373
1/4
✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2765 if (SIZEflags != 0) init_size_flags();;
10374 2765 }
10375
10376 623626 void eZora::facehero()
10377 {
10378
2/2
✓ Branch 0 taken 10785 times.
✓ Branch 1 taken 612841 times.
623626 if(Hero.x-x==0)
10379 {
10380 10785 dir=(Hero.y+8<y)?up:down;
10381 10785 }
10382 else
10383 {
10384 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10385 612841 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10386
10387
4/4
✓ Branch 0 taken 124342 times.
✓ Branch 1 taken 488499 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 78312 times.
612841 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10388 {
10389 78312 dir=l_down;
10390 78312 }
10391
4/4
✓ Branch 0 taken 90275 times.
✓ Branch 1 taken 444254 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 44245 times.
534529 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10392 {
10393 44245 dir=down;
10394 44245 }
10395
4/4
✓ Branch 0 taken 119526 times.
✓ Branch 1 taken 370758 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 73496 times.
490284 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10396 {
10397 73496 dir=r_down;
10398 73496 }
10399
4/4
✓ Branch 0 taken 160722 times.
✓ Branch 1 taken 256066 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 114692 times.
416788 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10400 {
10401 114692 dir=right;
10402 114692 }
10403
4/4
✓ Branch 0 taken 125815 times.
✓ Branch 1 taken 176281 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 79785 times.
302096 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10404 {
10405 79785 dir=r_up;
10406 79785 }
10407
4/4
✓ Branch 0 taken 87885 times.
✓ Branch 1 taken 134426 times.
✓ Branch 2 taken 46030 times.
✓ Branch 3 taken 41855 times.
222311 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10408 {
10409 41855 dir=up;
10410 41855 }
10411
4/4
✓ Branch 0 taken 120580 times.
✓ Branch 1 taken 59876 times.
✓ Branch 2 taken 74550 times.
✓ Branch 3 taken 46030 times.
180456 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10412 {
10413 74550 dir=l_up;
10414 74550 }
10415 else
10416 {
10417 105906 dir=left;
10418 }
10419 }
10420 623626 }
10421
10422 852265 bool eZora::animate(int32_t index)
10423 {
10424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 852265 times.
852265 if(switch_hooked) return enemy::animate(index);
10425
2/2
✓ Branch 0 taken 2754 times.
✓ Branch 1 taken 849511 times.
852265 if(dying)
10426 2754 return Dead(index);
10427
10428
2/2
✓ Branch 0 taken 843799 times.
✓ Branch 1 taken 5712 times.
849511 if(clk==0)
10429 {
10430 5712 removearmos(x,y,ffcactivated);
10431 5712 }
10432
10433
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 849476 times.
849511 if(watch)
10434 {
10435 35 ++clock_zoras[id];
10436 35 return true;
10437 }
10438
10439
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 623626 times.
849476 if(get_qr(qr_NEWENEMYTILES))
10440 {
10441 623626 facehero();
10442 623626 }
10443
10444
6/6
✓ Branch 0 taken 5200 times.
✓ Branch 1 taken 4963 times.
✓ Branch 2 taken 4164 times.
✓ Branch 3 taken 825736 times.
✓ Branch 4 taken 6448 times.
✓ Branch 5 taken 2965 times.
849476 switch(clk)
10445 {
10446 case 0: // reposition him
10447 {
10448 6448 int32_t t=0;
10449 6448 int32_t pos2=zc_oldrand()%160 + 16;
10450 6448 bool placed=false;
10451
10452
4/4
✓ Branch 0 taken 6383 times.
✓ Branch 1 taken 38203 times.
✓ Branch 2 taken 26108 times.
✓ Branch 3 taken 5712 times.
44586 while(!placed && t<160)
10453 {
10454 26108 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10455
5/6
✓ Branch 0 taken 6570 times.
✓ Branch 1 taken 19538 times.
✓ Branch 2 taken 6570 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5647 times.
32155 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10456
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6538 times.
6570 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10457
3/4
✓ Branch 0 taken 6538 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6047 times.
✓ Branch 3 taken 6015 times.
6570 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10458 {
10459 5647 x=(pos2&15)<<4;
10460 5647 y=pos2&0xF0;
10461
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5307 times.
5647 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10462 5647 hxofs=1000; // avoid hit detection
10463 5647 stunclk=0;
10464 5647 placed=true;
10465 5647 }
10466
10467 38138 pos2+=19;
10468
10469
2/2
✓ Branch 0 taken 33615 times.
✓ Branch 1 taken 4523 times.
38138 if(pos2>=176)
10470 4523 pos2-=160;
10471
10472 38138 ++t;
10473 }
10474
10475
3/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5647 times.
5712 if(!placed || whistleclk>=88) // can't place him, he's gone
10476 65 return true;
10477
10478 }
10479 5647 break;
10480
10481 case 35:
10482
2/2
✓ Branch 0 taken 3839 times.
✓ Branch 1 taken 1361 times.
5200 if(!get_qr(qr_NEWENEMYTILES))
10483 {
10484 1361 dir=(Hero.y+8<y)?up:down;
10485 1361 }
10486
10487 5200 hxofs=0;
10488 5200 break;
10489
10490 case 35+19:
10491 4963 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10492 4963 sfx(wpnsfx(wpn),pan(int32_t(x)));
10493 4963 break;
10494
10495 case 35+66:
10496 4164 hxofs=1000;
10497 4164 break;
10498
10499 case 198:
10500 2965 clk=-1;
10501 2965 break;
10502 }
10503
10504 848675 return enemy::animate(index);
10505 851529 }
10506
10507 857650 void eZora::draw(BITMAP *dest)
10508 {
10509
2/2
✓ Branch 0 taken 16963 times.
✓ Branch 1 taken 840687 times.
857650 if(clk<3)
10510 16963 return;
10511
10512 840687 update_enemy_frame();
10513 840687 enemy::draw(dest);
10514 857650 }
10515
10516 232 bool eZora::isSubmerged() const
10517 {
10518 232 return ( clk < 3 );
10519 }
10520
10521
3/6
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50116 times.
✗ Branch 5 not taken.
100232 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10522 50116 {
10523 50116 multishot= timer = fired = dashing = 0;
10524 50116 hashero = false;
10525 50116 dummy_bool[0]=false;
10526
4/8
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50116 times.
✗ Branch 7 not taken.
50116 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10527
5/6
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 49154 times.
✓ Branch 2 taken 962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 495 times.
✓ Branch 5 taken 467 times.
50116 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10528 {
10529
2/4
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 495 times.
✗ Branch 3 not taken.
495 step=zslongToFix(dmisc10*100);
10530
10531
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 477 times.
495 if(anim==aARMOS4) o_tile+=20;
10532 495 }
10533
10534
3/4
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 49154 times.
50116 if(flags & guy_fade_flicker)
10535 {
10536 962 clk=0;
10537 962 superman = 1;
10538 962 fading=fade_flicker;
10539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10540 962 dir=down;
10541
10542
4/6
✓ Branch 0 taken 962 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✓ Branch 5 taken 553 times.
962 if(!canmove(down,(zfix)8,spw_none,false))
10543
3/6
✓ Branch 0 taken 409 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 409 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
409 clk3=int32_t(13.0/step);
10544 962 }
10545
3/4
✓ Branch 0 taken 49154 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49021 times.
✓ Branch 3 taken 133 times.
49154 else if(flags & guy_fade_instant)
10546 {
10547 133 clk=0;
10548 133 }
10549
10550
1/2
✓ Branch 0 taken 50116 times.
✗ Branch 1 not taken.
50116 shadowdistance = 0;
10551 50116 clk4 = clk5 = 0;
10552 //nets+2380;
10553
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50114 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
50116 if (SIZEflags != 0) init_size_flags();;
10554 50116 }
10555
10556 15799295 bool eStalfos::animate(int32_t index)
10557 {
10558
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15799039 times.
15799295 if(switch_hooked) return enemy::animate(index);
10559
3/4
✓ Branch 0 taken 15798613 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15798613 times.
15799039 if(fallclk||drownclk)
10560 {
10561 426 return enemy::animate(index);
10562 }
10563
2/2
✓ Branch 0 taken 352690 times.
✓ Branch 1 taken 15445923 times.
15798613 if(dying)
10564 {
10565
2/2
✓ Branch 0 taken 352642 times.
✓ Branch 1 taken 48 times.
352690 if(hashero)
10566 {
10567 48 Hero.setEaten(0);
10568 48 hashero=false;
10569 48 }
10570
10571
10/14
✓ Branch 0 taken 35920 times.
✓ Branch 1 taken 316770 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32235 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
352690 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10572 {
10573 187 hp=-1000;
10574
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10575 187 Ewpns.add(ew);
10576 187 ew->fakez = fakez;
10577
10578
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10579 {
10580 187 ew->step=0;
10581 187 ew->id=wpn;
10582 187 ew->misc=50;
10583 187 ew->clk=48;
10584 187 }
10585
10586 187 fired=true;
10587 187 }
10588
6/6
✓ Branch 0 taken 156270 times.
✓ Branch 1 taken 196233 times.
✓ Branch 2 taken 130218 times.
✓ Branch 3 taken 26052 times.
✓ Branch 4 taken 130200 times.
✓ Branch 5 taken 18 times.
352503 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10589 {
10590
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10591 {
10592 1 int32_t wpn2 = wpn+dmisc3;
10593
10594
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10595 {
10596 wpn2=wpn;
10597 }
10598
10599 1 dummy_bool[0]=true;
10600 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10601 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10602 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10603 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10604 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10605 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10606 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10607 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10608 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10609 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10610 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10611 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10612 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10613 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10614 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10615 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10616 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10617 1 }
10618 18 }
10619
10620 352690 KillWeapon();
10621 352690 return Dead(index);
10622 }
10623 //vire split
10624 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10625 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10626
13/14
✓ Branch 0 taken 21125 times.
✓ Branch 1 taken 15424798 times.
✓ Branch 2 taken 21125 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20774 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14252876 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15445923 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10627 {
10628 1677 stop_bgsfx(index);
10629 1677 int32_t kids = guys.Count();
10630 1677 int32_t id2=dmisc3;
10631
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10632 {
10633 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10634
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10635 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10636 3307 }
10637
10638
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 1 times.
1677 if(itemguy) // Hand down the carried item
10639 {
10640 1 guycarryingitem = guys.Count()-1;
10641 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10642 1 itemguy = false;
10643 1 }
10644
10645
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10646 {
10647 17 Hero.setEaten(0);
10648 17 hashero=false;
10649 17 }
10650
10651
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10652 323 sfx(deadsfx,pan(int32_t(x)));
10653
10654 1677 return true;
10655 }
10656 /*
10657 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
10658 {
10659 stop_bgsfx(index);
10660 int32_t kids = guys.Count();
10661 int32_t id2=dmisc3;
10662
10663 for(int32_t i=0; i < dmisc4; i++)
10664 {
10665 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10666 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
10667 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10668 }
10669
10670 if(itemguy) // Hand down the carried item
10671 {
10672 guycarryingitem = guys.Count()-1;
10673 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10674 itemguy = false;
10675 }
10676
10677 if(hashero)
10678 {
10679 Hero.setEaten(0);
10680 hashero=false;
10681 }
10682
10683 return true;
10684 }
10685 */
10686
2/2
✓ Branch 0 taken 68935 times.
✓ Branch 1 taken 15375311 times.
15444246 if(fading)
10687 {
10688
2/2
✓ Branch 0 taken 1191 times.
✓ Branch 1 taken 67744 times.
68935 if(++clk4 > 60)
10689 {
10690 1191 clk4=0;
10691 1191 superman=0;
10692 1191 fading=0;
10693
10694
4/6
✓ Branch 0 taken 930 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 930 times.
1191 if(flags2&guy_armos && z==0 && fakez == 0)
10695 {
10696 //if a custom size (not 16px by 16px)
10697
10698 //if a custom size (not 16px by 16px)
10699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930 times.
930 if (ffcactivated)
10700 removearmosffc(ffcactivated-1);
10701 else
10702 {
10703
4/8
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 930 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 930 times.
930 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10704 {
10705 //zprint("spawn big enemy from armos\n");
10706 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10707 for(int32_t dx = 0; dx < tysz; dx ++)
10708 {
10709 for(int32_t dy = 0; dy < tysz; dy++)
10710 {
10711 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10712 did_armos = false;
10713 }
10714 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10715 did_armos = false;
10716 }
10717 for(int32_t dy = 0; dy < tysz; dy ++)
10718 {
10719 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10720 did_armos = false;
10721 }
10722 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10723 }
10724 930 else removearmos(x,y);
10725 }
10726 /*
10727 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10728 {
10729 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10730 for(int32_t dx = 0; dx < hxsz; dx += 16)
10731 {
10732 for(int32_t dy = 0; dy < hysz; dy += 16)
10733 {
10734 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
10735 did_armos = false;
10736 }
10737 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
10738 did_armos = false;
10739 }
10740 for(int32_t dy = 0; dy < hysz; dy += 16)
10741 {
10742 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
10743 did_armos = false;
10744 }
10745 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
10746 }
10747 else removearmos(x,y,ffcactivated);
10748 */
10749
10750 930 }
10751
10752 1191 clk2=0;
10753
10754 1191 newdir();
10755 1191 }
10756 67744 else return enemy::animate(index);
10757 1191 }
10758
6/8
✓ Branch 0 taken 144960 times.
✓ Branch 1 taken 15230351 times.
✓ Branch 2 taken 144960 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 144960 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135643 times.
✓ Branch 7 taken 9317 times.
15375311 else if(flags2&guy_armos && z==0 && fakez == 0 && clk==0)
10759 9317 removearmos(x,y,ffcactivated);
10760
10761
10762
2/2
✓ Branch 0 taken 7207 times.
✓ Branch 1 taken 15369295 times.
15376502 if(hashero)
10763 {
10764 7207 Hero.setX(x);
10765 7207 Hero.setY(y);
10766 7207 ++clk2;
10767
10768
4/4
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6308 times.
✓ Branch 3 taken 899 times.
7207 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10769 {
10770
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
899 switch(dmisc7)
10771 {
10772 case e7tEATITEMS:
10773 {
10774
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<MAXITEMS; i++)
10775 {
10776
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 if(itemsbuf[i].flags&item_edible)
10777 22 game->set_item(i, false);
10778 5632 }
10779
10780 22 break;
10781 }
10782
10783 case e7tEATMAGIC:
10784 game->change_dmagic(-1*game->get_magicdrainrate());
10785 break;
10786
10787 case e7tEATRUPEES:
10788 game->change_drupy(-1);
10789 break;
10790 }
10791
10792 899 clk2=0;
10793 899 }
10794
10795
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 6661 times.
7207 if((clk&0x18)==8) // stop its animation on the middle frame
10796 6661 --clk;
10797 7207 }
10798
4/4
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14320422 times.
✓ Branch 2 taken 616037 times.
✓ Branch 3 taken 432836 times.
15369295 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10799 {
10800 // Movement engine
10801
6/6
✓ Branch 0 taken 838865 times.
✓ Branch 1 taken 14097594 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14094133 times.
✓ Branch 5 taken 59 times.
14936459 if(clk>=0) switch(id>>12)
10802 {
10803 case 0: // Normal movement
10804
10805 /*
10806 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10807 {
10808 // Overloading clk4 (Tribble clock) here...
10809 step=17/100.0;
10810 if(clk4<32) misc=1;
10811 else if(clk4<48) misc=2;
10812 else if(clk4<300) { misc=3; step = dstep/100.0; }
10813 else if(clk4<316) misc=2;
10814 else if(clk4<412) misc=1;
10815 else if(clk4<540) { misc=0; step=0; }
10816 else clk4=0;
10817 if(clk4==48) clk=0;
10818 hxofs=(misc>=2)?0:1000;
10819 if (dmisc9==e9tLEEVER)
10820 variable_walk(rate, homing, 0);
10821 else
10822 variable_walk_8(rate, homing, 4, 0);
10823 break;
10824 }
10825 */
10826
4/4
✓ Branch 0 taken 13715099 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13298023 times.
14094133 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10827 {
10828 796110 vire_hop();
10829 796110 break;
10830 }
10831
2/2
✓ Branch 0 taken 981551 times.
✓ Branch 1 taken 12316472 times.
13298023 else if(dmisc9==e9tROPE) //Rope charge
10832 {
10833
9/10
✓ Branch 0 taken 964129 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 138340 times.
✓ Branch 3 taken 825789 times.
✓ Branch 4 taken 126255 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 125430 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 125430 times.
981551 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10834 {
10835
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 116354 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
125430 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10836 {
10837
10838
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10839 {
10840 14 hp=-1000;
10841
10842
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10843 {
10844
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10845 14 Ewpns.add(ew);
10846 14 ew->fakez = fakez;
10847
10848
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10849 {
10850 14 ew->step=0;
10851 14 ew->id=wpn+dmisc3;
10852 14 ew->misc=50;
10853 14 ew->clk=48;
10854 14 }
10855
10856 14 fired=true;
10857 14 }
10858 else
10859 {
10860 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10861 Ewpns.add(ew);
10862 ew->fakez = fakez;
10863
10864 if(wpn==ewSBomb || wpn==ewBomb)
10865 {
10866 ew->step=0;
10867 ew->id=wpn;
10868 ew->misc=50;
10869 ew->clk=48;
10870 }
10871
10872 fired=true;
10873 }
10874 14 }
10875
10876 else
10877 {
10878 33 hp=-1000;
10879
10880 int32_t wpn2;
10881
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10882 33 wpn2=wpn;
10883 else
10884 wpn2=wpn;
10885
10886
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10887 33 Ewpns.add(ew);
10888 33 ew->fakez = fakez;
10889
10890
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10891 {
10892 33 ew->step=0;
10893 33 ew->id=wpn2;
10894 33 ew->misc=50;
10895 33 ew->clk=48;
10896 33 }
10897
10898 33 fired=true;
10899 }
10900 47 }
10901 125430 }
10902
10903 981551 charge_attack();
10904 981551 break;
10905 }
10906 /*
10907 * Boomerang-throwers have a halt count of 1
10908 * Zols have a halt count of (zc_oldrand()&7)<<4
10909 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10910 * Everything else has 48
10911 */
10912 else
10913 {
10914
2/2
✓ Branch 0 taken 568419 times.
✓ Branch 1 taken 11748053 times.
12316472 if(wpn==ewBrang) // Goriya
10915 {
10916 568419 halting_walk(rate,homing,0,hrate, 1);
10917 568419 }
10918
4/4
✓ Branch 0 taken 11602163 times.
✓ Branch 1 taken 145890 times.
✓ Branch 2 taken 4547555 times.
✓ Branch 3 taken 7054608 times.
11748053 else if(dmisc9==e9tNORMAL && wpn==0)
10919 {
10920
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6336635 times.
7054608 if(dmisc2==e2tSPLITHIT) // Zol
10921 {
10922 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10923 717973 }
10924
4/4
✓ Branch 0 taken 1753011 times.
✓ Branch 1 taken 4583624 times.
✓ Branch 2 taken 1537120 times.
✓ Branch 3 taken 215891 times.
6336635 else if(frate<=8 && starting_hp==1) // Gel
10925 {
10926 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10927 215891 }
10928 else // Other
10929 {
10930 6120744 halting_walk(rate,homing,0,hrate, 48);
10931 }
10932 7054608 }
10933 else // Other
10934 {
10935 4693445 halting_walk(rate,homing,0,hrate, 48);
10936 }
10937 }
10938
10939 //if not in midair, and Hero's swinging sword is nearby, jump.
10940 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10941 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10942 {
10943 facehero(false);
10944 sclk=16+((dir^1)<<8);
10945 fall=-FEATHERJUMP;
10946 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
10947 }*/
10948 12316472 break;
10949
10950 // Following cases are for just after creation-by-splitting.
10951 case 1:
10952
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
10953 {
10954 821 dir=up;
10955 821 step=8;
10956 821 }
10957
10958
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
10959 {
10960 2504 move(step);
10961
10962
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
10963 512 dir=down;
10964 2504 }
10965
10966
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
10967 {
10968
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
10969 503 x+=16;
10970 790 }
10971
10972 3294 ++misc;
10973 3294 break;
10974
10975 case 2:
10976
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
10977 {
10978 15 dir=down;
10979 15 step=8;
10980 15 }
10981
10982
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
10983 {
10984 45 move(step);
10985 /*
10986 if(!canmove(dir,(zfix)0,0,false))
10987 dir=up;
10988 */
10989 45 }
10990
10991
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
10992 {
10993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
10994 14 x-=16;
10995 14 }
10996
10997 59 ++misc;
10998 59 break;
10999
11000 default:
11001
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11002 {
11003 28 dir=(zc_oldrand()%4);
11004 28 step=8;
11005 28 }
11006
11007
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11008 {
11009 83 move(step);
11010
11011
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11012 2 dir=dir^1;
11013 83 }
11014
11015
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11016 {
11017
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11018 8 x+=(dir==left ? -16 : 16);
11019 25 }
11020
11021 108 ++misc;
11022 108 break;
11023 14097594 }
11024
11025
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14911187 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14936459 if(id>>12 && misc>=4) //recently spawned by a split enemy
11026 {
11027 829 id&=0xFFF;
11028 829 step = zslongToFix(dstep*100);
11029
11030
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11031
11032
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>208) x=208;
11033
11034
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11035
11036
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>128) y=128;
11037
11038 829 misc=3;
11039 829 }
11040 14936459 }
11041 else
11042 {
11043 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11044
1/2
✓ Branch 0 taken 432836 times.
✗ Branch 1 not taken.
432836 if(clk2>2) clk2--;
11045 }
11046
11047 // Fire Zol
11048
8/8
✓ Branch 0 taken 6100125 times.
✓ Branch 1 taken 9276377 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5960844 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15376502 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11049 {
11050 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11051 1102 sfx(wpnsfx(wpn),pan(int32_t(x)));
11052
11053 1102 int32_t i=Ewpns.Count()-1;
11054 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11055
11056
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11057 {
11058 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11059 if ( ew->do_animation ) ew->tile+=ew->aframe;
11060 }
11061 1102 }
11062 // Goriya
11063
14/16
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14326527 times.
✓ Branch 2 taken 468534 times.
✓ Branch 3 taken 580339 times.
✓ Branch 4 taken 456235 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423258 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420517 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420517 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414155 times.
✓ Branch 15 taken 6362 times.
15375400 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11064 {
11065 6362 misc=index+100;
11066
7/14
✓ Branch 0 taken 6362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6362 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6362 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6362 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6362 times.
✗ Branch 13 not taken.
6362 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11067 6362 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11068
11069
2/2
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 257 times.
6362 if(dmisc1==2)
11070 {
11071 257 int32_t ndir=dir;
11072
11073
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11074 {
11075 6 ndir=(Hero.y+8<y)?up:down;
11076 6 }
11077 else //turn to face Hero
11078 {
11079 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11080 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11081
11082
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11083 {
11084 13 ndir=down;
11085 13 }
11086
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11087 {
11088 68 ndir=right;
11089 68 }
11090
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11091 {
11092 48 ndir=up;
11093 48 }
11094 else
11095 {
11096 122 ndir=left;
11097 }
11098 }
11099
11100 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11101
11102
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11103 {
11104 223 dir=ndir;
11105 223 }
11106 257 }
11107 6362 }
11108
15/16
✓ Branch 0 taken 15310158 times.
✓ Branch 1 taken 58880 times.
✓ Branch 2 taken 221196 times.
✓ Branch 3 taken 15147842 times.
✓ Branch 4 taken 195078 times.
✓ Branch 5 taken 26118 times.
✓ Branch 6 taken 170186 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168774 times.
✓ Branch 9 taken 1412 times.
✓ Branch 10 taken 153626 times.
✓ Branch 11 taken 15148 times.
✓ Branch 12 taken 153626 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152682 times.
15369038 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11109
3/3
✓ Branch 0 taken 26116 times.
✓ Branch 1 taken 125660 times.
✓ Branch 2 taken 906 times.
152682 switch(dmisc1)
11110 {
11111 case e1tCONSTANT: //Deathnut
11112 {
11113 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11114
2/2
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 2581 times.
125660 if(clk5>64)
11115 {
11116 2581 clk5=0;
11117 2581 fired=false;
11118 2581 }
11119
11120 125660 clk5+=(zc_oldrand()&3);
11121
11122
4/4
✓ Branch 0 taken 76669 times.
✓ Branch 1 taken 48991 times.
✓ Branch 2 taken 25622 times.
✓ Branch 3 taken 51047 times.
125660 if((clk5>24)&&(clk5<52))
11123 {
11124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51047 times.
51047 if ( do_animation )tile+=20; //firing
11125
11126
4/4
✓ Branch 0 taken 27950 times.
✓ Branch 1 taken 23097 times.
✓ Branch 2 taken 25124 times.
✓ Branch 3 taken 2826 times.
51047 if(!fired&&(clk5>=38))
11127 {
11128
5/10
✓ Branch 0 taken 2826 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2826 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2826 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2826 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2826 times.
✗ Branch 9 not taken.
2826 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11129 2826 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11130 2826 sfx(wpnsfx(wpn),pan(int32_t(x)));
11131 2826 fired=true;
11132 2826 }
11133 51047 }
11134
11135 125660 break;
11136 }
11137
11138 case e1tFIREOCTO: //Fire Octo
11139 906 timer=zc_oldrand()%50+50;
11140 906 break;
11141
11142 default:
11143 26116 FireWeapon();
11144 26116 break;
11145 152682 }
11146
11147 /* Fire again if:
11148 * - clk2 about to run out
11149 * - not already double-firing (dmisc1 is 1)
11150 * - not carrying Hero
11151 * - one in 0xF chance
11152 */
11153
8/10
✓ Branch 0 taken 524932 times.
✓ Branch 1 taken 14851570 times.
✓ Branch 2 taken 4002 times.
✓ Branch 3 taken 520930 times.
✓ Branch 4 taken 4002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3751 times.
✓ Branch 9 taken 251 times.
15376502 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11154 {
11155 #if 1
11156 251 newdir(rate, homing, grumble);
11157 #else
11158 dir^=2;
11159 #endif
11160 251 clk2=28;
11161 251 ++multishot;
11162 251 }
11163
11164
2/2
✓ Branch 0 taken 3492313 times.
✓ Branch 1 taken 11884189 times.
15376502 if(clk2==0)
11165 {
11166 11884189 multishot = 0;
11167 11884189 }
11168
11169
2/2
✓ Branch 0 taken 15312192 times.
✓ Branch 1 taken 64310 times.
15376502 if(timer) //Fire Octo
11170 {
11171 64310 clk2=15; //this keeps the octo in place until he's done firing
11172
11173
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11174 {
11175 15752 FireBreath(false);
11176 15752 }
11177
11178 64310 --timer;
11179 64310 }
11180
11181
2/2
✓ Branch 0 taken 15127109 times.
✓ Branch 1 taken 249393 times.
15376502 if(dmisc2==e2tTRIBBLE)
11182 249393 ++clk4;
11183
11184
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15372022 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15375809 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15376502 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11185 {
11186 693 int32_t kids = guys.Count();
11187 693 int32_t id2=dmisc3;
11188
11189
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11190 {
11191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(x,y,id2,-24))
11192 {
11193
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11194 {
11195 guycarryingitem = guys.Count()-1;
11196 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11197 itemguy = false;
11198 }
11199
11200 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11201 693 }
11202 693 }
11203
11204
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11205 {
11206 Hero.setEaten(0);
11207 hashero=false;
11208 }
11209
11210 693 stop_bgsfx(index);
11211 693 return true;
11212 }
11213
11214 15375809 return enemy::animate(index);
11215 15799295 }
11216
11217 16194890 void eStalfos::draw(BITMAP *dest)
11218 {
11219 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
11220 {
11221 clk4--; //Kludge
11222 return;
11223 }*/
11224
11225 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
11226 {
11227 cs = dcset;
11228 }*/
11229 16194890 update_enemy_frame();
11230
11231
7/8
✓ Branch 0 taken 16194464 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16194464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16107513 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16194890 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11232 {
11233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11234 11115 }
11235
11236 16194890 enemy::draw(dest);
11237 16194890 }
11238
11239 7494226 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11240 {
11241 7494226 int32_t tempy=yofs;
11242
11243 /*
11244 if (clk6 && dir>=left && !get_qr(qr_ENEMIESZAXIS)) {
11245 flip = 0;
11246 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11247 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
11248 shadowtile = wpnsbuf[spr_shadow].tile+f2;
11249 yofs+=(((int32_t)y+17)&0xF0)-y;
11250 yofs+=8;
11251 }
11252 */
11253
4/4
✓ Branch 0 taken 7278808 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7182607 times.
✓ Branch 3 taken 311619 times.
7494226 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11254 {
11255 311619 flip = 0;
11256 311619 int32_t fdiv = frate/4;
11257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11258
11259
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11260 311619 efrate:((clk>=(frate>>1))?1:0);
11261 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11262
11263
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11264 {
11265 311619 shadowtile+=f2;
11266 311619 }
11267 else
11268 {
11269 shadowtile+=f2?1:0;
11270 }
11271
11272 311619 yofs+=shadowdistance;
11273 311619 yofs+=8;
11274 311619 }
11275
4/4
✓ Branch 0 taken 7278808 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7491191 times.
✓ Branch 3 taken 3035 times.
7494226 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11276 {
11277 3035 flip = 0;
11278 3035 int32_t fdiv = frate/4;
11279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11280
11281
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11282 3035 efrate:((clk>=(frate>>1))?1:0);
11283 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11284
11285
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11286 {
11287 3035 shadowtile+=f2;
11288 3035 }
11289 else
11290 {
11291 shadowtile+=f2?1:0;
11292 }
11293 3035 }
11294
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 7488730 times.
7494226 if(!shadow_overpit(this))
11295 7488730 enemy::drawshadow(dest, translucent);
11296 7494226 yofs=tempy;
11297 7494226 }
11298
11299 157627 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11300 {
11301 157627 int32_t wpnId = w->id;
11302 157627 int32_t wpnDir = w->dir;
11303
11304
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156209 times.
✓ Branch 2 taken 546 times.
✓ Branch 3 taken 872 times.
157627 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11305
5/8
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 546 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 361 times.
✓ Branch 5 taken 185 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 185 times.
546 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11306
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 185 times.
185 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11307 {
11308 361 shield = false;
11309 361 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11310
11311
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 256 times.
361 if(get_qr(qr_BRKNSHLDTILES))
11312 256 o_tile=s_tile;
11313 361 }
11314
11315 157627 int32_t ret = enemy::takehit(w,realweap);
11316
11317
4/4
✓ Branch 0 taken 22313 times.
✓ Branch 1 taken 135314 times.
✓ Branch 2 taken 20562 times.
✓ Branch 3 taken 1751 times.
157627 if(sclk && dmisc2==e2tSPLITHIT)
11318 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11319
11320 157627 return ret;
11321 }
11322
11323 981551 void eStalfos::charge_attack()
11324 {
11325
2/2
✓ Branch 0 taken 6715 times.
✓ Branch 1 taken 974836 times.
981551 if(slide())
11326 6715 return;
11327
11328
10/12
✓ Branch 0 taken 974836 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 972432 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 942919 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 921366 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 915743 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 915743 times.
974836 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11329 59093 return;
11330
11331
2/2
✓ Branch 0 taken 37390 times.
✓ Branch 1 taken 878353 times.
915743 if(clk3<=0)
11332 {
11333 37390 fix_coords(true);
11334
11335
2/2
✓ Branch 0 taken 10009 times.
✓ Branch 1 taken 27381 times.
37390 if(!dashing)
11336 {
11337 27381 int32_t ldir = lined_up(7,false);
11338
11339
4/4
✓ Branch 0 taken 3087 times.
✓ Branch 1 taken 24294 times.
✓ Branch 2 taken 452 times.
✓ Branch 3 taken 2635 times.
27381 if(ldir!=-1 && canmove(ldir,false))
11340 {
11341 2635 dir=ldir;
11342 2635 dashing=true;
11343
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2635 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2635 if(dmisc10<=0 || replay_version_check(0,33))
11344 2635 step=zslongToFix(dstep*100)+1;
11345 else
11346 step=zslongToFix(dmisc10*100);
11347 2635 }
11348 24746 else newdir(4,0,0);
11349 27381 }
11350
11351
2/2
✓ Branch 0 taken 35948 times.
✓ Branch 1 taken 1442 times.
37390 if(!canmove(dir,false))
11352 {
11353 1442 step=zslongToFix(dstep*100);
11354 1442 newdir();
11355 1442 dashing=false;
11356 1442 }
11357
11358 37390 zfix div = step;
11359
11360
1/2
✓ Branch 0 taken 37390 times.
✗ Branch 1 not taken.
37390 if(div == 0)
11361 div = 1;
11362
11363 37390 clk3=(int32_t)(16.0/div);
11364 37390 return;
11365 }
11366
11367 878353 move(step);
11368 878353 --clk3;
11369 981551 }
11370
11371 796110 void eStalfos::vire_hop()
11372 {
11373 //if ( sclk > 0 ) return; //Don't hop during knockback.
11374
11375 // if(dmisc9!=e9tPOLSVOICE)
11376 // {
11377 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11378 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11379 // return; //the enemy should split if it is sliding!
11380 // //else sclk=0; //might need this here, too. -Z
11381 // }
11382
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11383 {
11384
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11385 {
11386
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11387 //return;
11388 3843 }
11389 376292 }
11390 417076 else sclk=0;
11391
11392
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11393 31892 return;
11394
11395 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11396 761476 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
11397
11398 761476 y=floor_y;
11399
11400
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11401 {
11402 26258 fix_coords();
11403
11404 //z=0;
11405 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11406 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11407
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11408 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11409
11410
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11411 {
11412 //z=0;
11413
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11414 {
11415
11416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11417 /*if (dmisc9==e9tPOLSVOICE )
11418 {
11419 zprint2("polsvoice jump_width is: %d\n", jump_width);
11420 zprint2("polsvoice raw step is: %d\n", step);
11421 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
11422 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
11423 }
11424 else
11425 {
11426 zprint2("vire jump_width is: %d\n", jump_width);
11427 zprint2("vire raw step is: %d\n", step);
11428 zprint2("vire step.getInt() is: %d\n", step.getInt());
11429 zprint2("setting clk2 on vire to: %d\n", clk2);
11430 }
11431 */
11432 17258 }
11433 21336 }
11434
11435
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11436 {
11437 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11438 7030 }
11439
11440 26258 clk3=int32_t(16.0/step.getFloat());
11441 26258 }
11442
11443 761476 --clk3;
11444
11445
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11446 761476 move(step);
11447
11448 761476 floor_y=y;
11449 761476 clk2--;
11450
11451 //if we're in the middle of a jump
11452
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11453 {
11454 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11455
11456
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11457 {
11458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11459 93147 else z=h;
11460 93147 }
11461 else
11462 {
11463 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
11464 //y-=h;
11465 384731 y=floor_y-h;
11466 384731 shadowdistance=h;
11467 }
11468 477878 }
11469 else
11470 283598 shadowdistance = 0;
11471 796110 }
11472
11473 138 void eStalfos::eathero()
11474 {
11475
5/8
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70 times.
138 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11476 {
11477 70 hashero=true;
11478 70 y=floor_y;
11479 70 z=0;
11480
11481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(Hero.isSwimming())
11482 {
11483 Hero.setX(x);
11484 Hero.setY(y);
11485 }
11486 else
11487 {
11488 70 x=Hero.getX();
11489 70 y=Hero.getY();
11490 }
11491
11492 70 clk2=0;
11493 70 }
11494 138 }
11495
11496 1469390 bool eStalfos::WeaponOut()
11497 {
11498
2/2
✓ Branch 0 taken 2400579 times.
✓ Branch 1 taken 622399 times.
3022978 for(int32_t i=0; i<Ewpns.Count(); i++)
11499 {
11500
3/4
✓ Branch 0 taken 846991 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846991 times.
✗ Branch 3 not taken.
2400579 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11501 {
11502 846991 return true;
11503 }
11504
11505 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
11506 stop_sfx(bgsfx);
11507 */
11508 1553588 }
11509
11510 622399 return false;
11511 1469390 }
11512
11513 352690 void eStalfos::KillWeapon()
11514 {
11515
2/2
✓ Branch 0 taken 352690 times.
✓ Branch 1 taken 293384 times.
646074 for(int32_t i=0; i<Ewpns.Count(); i++)
11516 {
11517
4/4
✓ Branch 0 taken 245286 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 244476 times.
✓ Branch 3 taken 810 times.
293384 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11518 {
11519 //only kill this Goriya's boomerang -DD
11520
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11521 {
11522 411 Ewpns.del(i);
11523 411 }
11524 810 }
11525 293384 }
11526
11527
4/4
✓ Branch 0 taken 26052 times.
✓ Branch 1 taken 326638 times.
✓ Branch 2 taken 14170 times.
✓ Branch 3 taken 11882 times.
352690 if(wpn==ewBrang && !Ewpns.idCount(ewBrang))
11528 {
11529 14170 stop_sfx(WAV_BRANG);
11530 14170 }
11531 352690 }
11532
11533 void eStalfos::break_shield()
11534 {
11535 if(!shield)
11536 return;
11537
11538 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11539 shield=false;
11540
11541 if(get_qr(qr_BRKNSHLDTILES))
11542 o_tile=s_tile;
11543 }
11544
11545 13582 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11546 13582 {
11547
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 dir=(zc_oldrand()&7)+8;
11548
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 step=0;
11549 13582 movestatus=1;
11550
3/4
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10458 times.
13582 if (dmisc1 != 1 && dmisc19 > 0)
11551 {
11552 step = dmisc19/100.0;
11553 movestatus = 1;
11554 }
11555
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if (dmisc1 == 2) movestatus=2;
11556 13582 c=0;
11557 13582 clk4=0;
11558 //nets;
11559
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 init_size_flags();
11560 13582 dummy_int[1]=0;
11561 13582 }
11562
11563 3505411 bool eKeese::animate(int32_t index)
11564 {
11565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3505411 times.
3505411 if(switch_hooked) return enemy::animate(index);
11566
2/4
✓ Branch 0 taken 3505411 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3505411 times.
3505411 if(fallclk||drownclk) return enemy::animate(index);
11567
2/2
✓ Branch 0 taken 124201 times.
✓ Branch 1 taken 3381210 times.
3505411 if(dying)
11568 124201 return Dead(index);
11569
11570
2/2
✓ Branch 0 taken 3355205 times.
✓ Branch 1 taken 26005 times.
3381210 if(clk==0)
11571 {
11572 26005 removearmos(x,y,ffcactivated);
11573 26005 }
11574
11575
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2356168 times.
3381210 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11576 {
11577 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11578 1025042 }
11579 else
11580 {
11581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2356168 times.
2356168 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11582 2356168 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11583 }
11584
11585
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3260872 times.
3381210 if(dmisc2 == e2tKEESETRIB)
11586 {
11587
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11588 {
11589
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11590 {
11591 105 int32_t kids = guys.Count();
11592 105 bool success = false;
11593 105 int32_t id2=dmisc3;
11594 105 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
11595
11596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11597 {
11598
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11599 {
11600 guycarryingitem = guys.Count()-1;
11601 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11602 itemguy = false;
11603 }
11604
11605 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11606 105 }
11607
11608 105 stop_bgsfx(index);
11609 105 return true;
11610 }
11611 else
11612 {
11613 86 clk4=0;
11614 }
11615 86 }
11616 120233 }
11617 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11618
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2414993 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3260872 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11619 {
11620
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11621 {
11622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11623 {
11624 fakez=int32_t(step/zslongToFix(dstep*100));
11625 // Some variance in keese flight heights when away from Hero
11626 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11627
11628 }
11629 else
11630 {
11631 687068 z=int32_t(step/zslongToFix(dstep*100));
11632 // Some variance in keese flight heights when away from Hero
11633
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11634 }
11635 687068 }
11636 else
11637 {
11638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & move_use_fake_z)
11639 {
11640 fakez=int32_t(step/zslongToFix(dstep*100));
11641 // Some variance in keese flight heights when away from Hero
11642 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11643
11644 }
11645 else
11646 {
11647 158811 z=int32_t(step/zslongToFix(dstep*100));
11648 // Some variance in keese flight heights when away from Hero
11649
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11650 }
11651 }
11652 845879 }
11653
11654 3381105 return enemy::animate(index);
11655 3505411 }
11656
11657 2056065 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11658 {
11659 2056065 int32_t tempy=yofs;
11660 2056065 flip = 0;
11661 2056065 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11662
11663
2/2
✓ Branch 0 taken 653085 times.
✓ Branch 1 taken 1402980 times.
2056065 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11664
2/2
✓ Branch 0 taken 690563 times.
✓ Branch 1 taken 1365502 times.
2056065 if(!get_qr(qr_ENEMIESZAXIS))
11665 {
11666 1365502 yofs+=int32_t(step/zslongToFix(dstep*10));
11667 1365502 }
11668
11669
6/6
✓ Branch 0 taken 2035375 times.
✓ Branch 1 taken 20690 times.
✓ Branch 2 taken 676820 times.
✓ Branch 3 taken 1358555 times.
✓ Branch 4 taken 661452 times.
✓ Branch 5 taken 15368 times.
2056065 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
11670 2020007 enemy::drawshadow(dest, translucent);
11671 2056065 yofs=tempy;
11672 2056065 }
11673
11674 7885431 void eKeese::draw(BITMAP *dest)
11675 {
11676 7885431 update_enemy_frame();
11677 7885431 enemy::draw(dest);
11678 7885431 }
11679
11680 13582 void eKeese::init_size_flags()
11681 {
11682 13582 SIZEflags = d->SIZEflags;
11683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11684
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11685
11686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & guyflagOVERRIDE_HIT_WIDTH)) hit_width = 12;
11687
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11688
11689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11690
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11691
11692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
13582 if (!(SIZEflags & guyflagOVERRIDE_HIT_HEIGHT)) hit_height = 8;
11693
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11694
11695
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13582 if (((SIZEflags & guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11696 // al_trace("Enemy txsz:%i\n", txsz);
11697
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13582 if (((SIZEflags & guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11698
11699
11700
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13582 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13582 if (((SIZEflags & guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11701
11702
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & guyflagOVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11703
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & guyflagOVERRIDE_DRAW_Y_OFFSET) != 0)
11704 {
11705 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11706 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11707 }
11708
11709
1/2
✓ Branch 0 taken 13582 times.
✗ Branch 1 not taken.
13582 if ((SIZEflags & guyflagOVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11710 13582 }
11711
11712 20081 void eWizzrobe::submerge(bool set)
11713 {
11714
2/2
✓ Branch 0 taken 19934 times.
✓ Branch 1 taken 147 times.
20081 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11715 {
11716 19934 hxofs = set?1000:0;
11717 19934 return;
11718 }
11719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11720 147 submerged = set;
11721
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11722 76 hxofs+=1000;
11723 71 else hxofs -= 1000;
11724 20081 }
11725 5326 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11726 5326 {
11727 5326 hxofs = 0;
11728 5326 submerged = false;
11729
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2968 times.
5326 switch(dmisc1)
11730 {
11731 case 0:
11732 2968 submerge(true);
11733 2968 fading=fade_invisible;
11734 // Set clk to just before the 'reappear' threshold
11735
9/10
✓ Branch 0 taken 2967 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2967 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1784 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1783 times.
✓ Branch 9 taken 1 times.
2968 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11736 2968 break;
11737
11738 default:
11739 2358 dir=(loadside==right)?right:left;
11740 2358 misc=-3;
11741 2358 break;
11742 }
11743
11744 //netst+2880;
11745 5326 charging=false;
11746 5326 firing=false;
11747 5326 fclk=0;
11748
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2968 times.
5326 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11749
1/4
✓ Branch 0 taken 5326 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5326 if (SIZEflags != 0) init_size_flags();;
11750 5326 }
11751
11752 2075375 bool eWizzrobe::animate(int32_t index)
11753 {
11754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2075375 times.
2075375 if(switch_hooked) return enemy::animate(index);
11755
2/4
✓ Branch 0 taken 2075375 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2075375 times.
2075375 if(fallclk||drownclk) return enemy::animate(index);
11756
2/2
✓ Branch 0 taken 37967 times.
✓ Branch 1 taken 2037408 times.
2075375 if(dying)
11757 {
11758 37967 return Dead(index);
11759 }
11760
11761
2/2
✓ Branch 0 taken 1970803 times.
✓ Branch 1 taken 66605 times.
2037408 if(clk==0)
11762 {
11763 66605 removearmos(x,y,ffcactivated);
11764 66605 }
11765
11766
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1018188 times.
2037408 if(dmisc1) // Floating
11767 {
11768 1019220 wizzrobe_attack();
11769 1019220 }
11770 else // Teleporting
11771 {
11772
5/6
✓ Branch 0 taken 1011104 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1000017 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1018188 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11773 {
11774 7084 fading=0;
11775 7084 submerge(false);
11776 7084 solid_update(false);
11777 7084 }
11778
8/8
✓ Branch 0 taken 977386 times.
✓ Branch 1 taken 6199 times.
✓ Branch 2 taken 5284 times.
✓ Branch 3 taken 5122 times.
✓ Branch 4 taken 4977 times.
✓ Branch 5 taken 4222 times.
✓ Branch 6 taken 4084 times.
✓ Branch 7 taken 3830 times.
1011104 else switch(clk)
11779 {
11780 case 0:
11781
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5082 times.
6199 if(!dmisc2)
11782 {
11783 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11784 // but should not appear on dungeon walls.
11785
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4669 times.
5082 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11786
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4445 times.
4669 else if (editorflags&ENEMY_FLAG5)
11787 {
11788 //2.10 Windrobe
11789 //randomise location and face Hero
11790 224 int32_t t=0;
11791 224 bool placed=false;
11792
11793
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11794 {
11795
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon())
11796 {
11797 280 x=((zc_oldrand()%12)+2)*16;
11798 280 y=((zc_oldrand()%7)+2)*16;
11799 280 }
11800 else
11801 {
11802 87 x=((zc_oldrand()%14)+1)*16;
11803 87 y=((zc_oldrand()%9)+1)*16;
11804 }
11805
11806
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11807 {
11808 224 placed=true;
11809 224 }
11810
11811 367 ++t;
11812 }
11813
11814
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11815 {
11816
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11817 {
11818 47 dir=down;
11819 47 }
11820 else
11821 {
11822 14 dir=up;
11823 }
11824 61 }
11825 else
11826 {
11827
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11828 {
11829 72 dir=right;
11830 72 }
11831 else
11832 {
11833 91 dir=left;
11834 }
11835 }
11836
11837
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11838 return true;
11839
11840
11841 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11842 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11843 224 }
11844 4445 else place_on_axis(true, dmisc4!=0);
11845 5082 }
11846 else
11847 {
11848 1117 int32_t t=0;
11849 1117 bool placed=false;
11850
11851
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11852 {
11853
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon())
11854 {
11855 1340 x=((zc_oldrand()%12)+2)*16;
11856 1340 y=((zc_oldrand()%7)+2)*16;
11857 1340 }
11858 else
11859 {
11860 1103 x=((zc_oldrand()%14)+1)*16;
11861 1103 y=((zc_oldrand()%9)+1)*16;
11862 }
11863
11864
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11865 {
11866 1117 placed=true;
11867 1117 }
11868
11869 2443 ++t;
11870 }
11871
11872
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11873 {
11874
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11875 {
11876 238 dir=down;
11877 238 }
11878 else
11879 {
11880 148 dir=up;
11881 }
11882 386 }
11883 else
11884 {
11885
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11886 {
11887 340 dir=right;
11888 340 }
11889 else
11890 {
11891 391 dir=left;
11892 }
11893 }
11894
11895
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11896 return true;
11897 }
11898
11899 6199 fading=fade_flicker;
11900 6199 submerge(false);
11901 6199 solid_update(false);
11902 6199 break;
11903
11904 case 64:
11905 5284 fading=0;
11906 5284 charging=true;
11907 5284 break;
11908
11909 case 73:
11910 5122 charging=false;
11911 5122 firing=40;
11912 5122 break;
11913
11914 case 83:
11915 4977 wizzrobe_attack_for_real();
11916 4977 break;
11917
11918 case 119:
11919 4222 firing=false;
11920 4222 charging=true;
11921 4222 break;
11922
11923 case 128:
11924 4084 fading=fade_flicker;
11925 4084 charging=false;
11926 4084 break;
11927
11928 case 146:
11929 3830 fading=fade_invisible;
11930 3830 submerge(true);
11931 3830 solid_update(false);
11932
11933 [[fallthrough]];
11934 default:
11935
4/4
✓ Branch 0 taken 981056 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 975008 times.
✓ Branch 3 taken 6208 times.
981216 if(clk>=(146+zc_max(0,dmisc5)))
11936 6208 clk=-1;
11937
11938 981216 break;
11939 }
11940 }
11941
11942 2037408 return enemy::animate(index);
11943 2075375 }
11944
11945 7900 void eWizzrobe::wizzrobe_attack_for_real()
11946 {
11947
1/2
✓ Branch 0 taken 7900 times.
✗ Branch 1 not taken.
7900 if(wpn==0) // Edited enemies
11948 return;
11949
11950
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5917 times.
7900 if(dmisc2 == 0) //normal weapon
11951 {
11952 5917 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11953 5917 sfx(WAV_WAND,pan(int32_t(x)));
11954 5917 }
11955
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
11956 {
11957 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11958 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11959 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
11960 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11961 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
11962 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11963 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
11964 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11965 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
11966 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11967 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
11968 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11969 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
11970 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11971 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
11972 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11973 995 sfx(WAV_FIRE,pan(int32_t(x)));
11974
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX)) sfx(WAV_FIRE,pan(int32_t(x)));
11975 else
11976 {
11977
3/18
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
507 switch(wpn)
11978 {
11979 19 case ewFireball: sfx(40,pan(int32_t(x))); break;
11980
11981 case ewArrow: sfx(1,pan(int32_t(x))); break; //Ghost.zh has 0?
11982 case ewBrang: sfx(4,pan(int32_t(x))); break; //Ghost.zh has 0?
11983 case ewSword: sfx(20,pan(int32_t(x))); break; //Ghost.zh has 0?
11984 case ewRock: sfx(51,pan(int32_t(x))); break;
11985 68 case ewMagic: sfx(32,pan(int32_t(x))); break;
11986 case ewBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
11987 case ewSBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
11988 case ewLitBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
11989 case ewLitSBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
11990 case ewFireTrail: sfx(13,pan(int32_t(x))); break;
11991 420 case ewFlame: sfx(13,pan(int32_t(x))); break;
11992 case ewWind: sfx(32,pan(int32_t(x))); break;
11993 case ewFlame2: sfx(13,pan(int32_t(x))); break;
11994 case ewFlame2Trail: sfx(13,pan(int32_t(x))); break;
11995 case ewIce: sfx(44,pan(int32_t(x))); break;
11996 case ewFireball2: sfx(40,pan(int32_t(x))); break; //fireball (rising)
11997 default: sfx(WAV_FIRE,pan(int32_t(x))); break;
11998
11999 }
12000 }
12001 995 }
12002
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12003 {
12004 971 int32_t bc=0;
12005
12006
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12007 {
12008
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12009 {
12010 5195 ++bc;
12011 5195 }
12012 10497 }
12013
12014
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12015 {
12016 963 int32_t kids = guys.Count();
12017 963 int32_t bats=(zc_oldrand()%3)+1;
12018
12019
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12020 {
12021 // Summon bats (or anything)
12022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(x,y,dmisc3,-10, this->script_UID))
12023 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12024 1965 }
12025
12026 963 sfx(WAV_FIRE,pan(int32_t(x)));
12027 963 }
12028 971 }
12029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12030 {
12031
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies()==0)
12032 {
12033 return;
12034 }
12035
12036 17 int32_t kids = guys.Count();
12037
12038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12039 {
12040 17 int32_t newguys=(zc_oldrand()%3)+1;
12041 17 bool summoned=false;
12042
12043
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12044 {
12045 32 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
12046 32 int32_t x2=0;
12047 32 int32_t y2=0;
12048
12049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12050 {
12051 36 x2=16*((zc_oldrand()%12)+2);
12052 36 y2=16*((zc_oldrand()%7)+2);
12053
12054
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12055 {
12056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
12057 {
12058 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12059
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12060 {
12061 ((enemy*)guys.spr(kids+i))->fakez = 64;
12062 ((enemy*)guys.spr(kids+i))->z = 0;
12063 }
12064 32 }
12065
12066 32 summoned=true;
12067 32 break;
12068 }
12069 4 }
12070 32 }
12071
12072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12073 {
12074 17 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
12075 17 }
12076 17 }
12077 17 }
12078 7900 }
12079
12080
12081 1019220 void eWizzrobe::wizzrobe_attack()
12082 {
12083
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12084 86341 return;
12085
12086
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12087 {
12088 39538 fix_coords();
12089
12090
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12091 {
12092 case 1: //walking
12093
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12094 2644 misc=0;
12095 else
12096 {
12097 10364 clk3=16;
12098
12099
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12100 {
12101 1398 wizzrobe_newdir(0);
12102 1398 }
12103 }
12104
12105 13008 break;
12106
12107 case 2: //phasing
12108 {
12109 3903 int32_t jx=x;
12110 3903 int32_t jy=y;
12111 3903 int32_t jdir=-1;
12112
12113
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12114 {
12115 case 0:
12116 484 jx-=32;
12117 484 jy-=32;
12118 484 jdir=15;
12119 484 break;
12120
12121 case 1:
12122 472 jx+=32;
12123 472 jy-=32;
12124 472 jdir=9;
12125 472 break;
12126
12127 case 2:
12128 482 jx+=32;
12129 482 jy+=32;
12130 482 jdir=11;
12131 482 break;
12132
12133 case 3:
12134 492 jx-=32;
12135 492 jy+=32;
12136 492 jdir=13;
12137 492 break;
12138 }
12139
12140
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12141 {
12142 1140 misc=3;
12143 1140 clk3=32;
12144 1140 dir=jdir;
12145 1140 break;
12146 }
12147 2763 }
12148 [[fallthrough]];
12149 case 3:
12150 3813 dir&=3;
12151 3813 misc=0;
12152 [[fallthrough]];
12153 case 0:
12154 19894 wizzrobe_newdir(64);
12155 [[fallthrough]];
12156 default:
12157
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12158 {
12159
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12160 {
12161 3265 misc=1;
12162 3265 clk3=16;
12163 3265 }
12164 else
12165 {
12166 239 wizzrobe_newdir(64);
12167 239 misc=0;
12168 239 clk3=32;
12169 }
12170 3504 }
12171 else
12172 {
12173 21886 clk3=32;
12174 }
12175
12176 25390 break;
12177 }
12178
12179
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12180 4478 ++misc;
12181 39538 }
12182
12183 932879 --clk3;
12184
12185
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12186 {
12187 case 1:
12188 case 3:
12189 248377 step=1;
12190 248377 break;
12191
12192 case 2:
12193 63903 step=0;
12194 63903 break;
12195
12196 default:
12197 620599 step=0.5;
12198 620599 break;
12199
12200 }
12201
12202 932879 move(step);
12203
12204 // if(d->misc1 && misc<=0 && clk3==28)
12205
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12206 {
12207
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12208 {
12209
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12210 {
12211 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12212 // sfx(WAV_WAND,pan(int32_t(x)));
12213 1928 wizzrobe_attack_for_real();
12214 1928 fclk=30;
12215 1928 }
12216 16835 }
12217 else
12218 {
12219
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12220 {
12221 995 wizzrobe_attack_for_real();
12222 995 fclk=30;
12223 995 }
12224 }
12225 21547 }
12226
12227
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12228 4050 misc=2;
12229
12230
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12231 3441 fix_coords();
12232
12233
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12234 {
12235
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12236 {
12237 83282 --fclk;
12238 83282 }
12239 932879 }
12240
12241 1019220 }
12242
12243 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12244 {
12245 // Wizzrobes shouldn't move to the edge of the screen;
12246 // if they're already there, they should move toward the center
12247
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12248 33 dir=right;
12249
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=224)
12250 4 dir=left;
12251
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12252 2 dir=down;
12253
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=144)
12254 5 dir=up;
12255 else
12256 21487 newdir(4,homing,spw_wizzrobe);
12257 21531 }
12258
12259 2092991 void eWizzrobe::draw(BITMAP *dest)
12260 {
12261 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12262
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1050508 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2092991 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12263 125018 return;
12264
12265 1967973 int32_t tempint=dummy_int[1];
12266 1967973 bool tempbool1=dummy_bool[1];
12267 1967973 bool tempbool2=dummy_bool[2];
12268 1967973 dummy_int[1]=fclk;
12269 1967973 dummy_bool[1]=charging;
12270 1967973 dummy_bool[2]=firing;
12271 1967973 update_enemy_frame();
12272 1967973 dummy_int[1]=tempint;
12273 1967973 dummy_bool[1]=tempbool1;
12274 1967973 dummy_bool[2]=tempbool2;
12275 1967973 enemy::draw(dest);
12276 2092991 }
12277
12278 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12279 203 {
12280 203 fading=fade_flash_die;
12281
6/8
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12282 {
12283 3 dir=up;
12284 3 }
12285
12286
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
203 if(dir==right&&x>=208)
12287 {
12288 dir=left;
12289 }
12290
1/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if (SIZEflags != 0) init_size_flags();;
12291 203 }
12292
12293 125855 bool eDodongo::animate(int32_t index)
12294 {
12295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12296
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12297 {
12298 3790 return Dead(index);
12299 }
12300
12301
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12302 {
12303 569 removearmos(x,y,ffcactivated);
12304 569 }
12305
12306
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12307 {
12308
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12309 113 hp-=misc; // store bomb's power in misc
12310 10848 }
12311 else
12312 111217 constant_walk(rate,homing,spw_clipright);
12313
12314 122065 hit_width = (dir<=down) ? 16 : 32;
12315 // hysz = (dir>=left) ? 16 : 32;
12316
12317 122065 return enemy::animate(index);
12318 125855 }
12319
12320 125845 void eDodongo::draw(BITMAP *dest)
12321 {
12322 125845 tile=o_tile;
12323
12324
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12325 {
12326 3065 enemy::drawzcboss(dest);
12327 3065 return;
12328 }
12329
12330 122780 update_enemy_frame();
12331 122780 enemy::drawzcboss(dest);
12332
12333
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12334 {
12335 71118 tile+=dummy_int[1]; //second tile is previous tile
12336 71118 xofs-=16; //new xofs change
12337 71118 enemy::drawzcboss(dest);
12338 71118 xofs+=16;
12339 71118 }
12340
12341 125845 }
12342
12343 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12344 {
12345 8218 int32_t wpnId = w->id;
12346 8218 int32_t power = w->power;
12347 8218 int32_t wpnx = w->x;
12348 8218 int32_t wpny = w->y;
12349
12350
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12351 5761 return 0;
12352
12353
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12354 {
12355 case wPhantom:
12356 return 0;
12357
12358 case wFire:
12359 case wBait:
12360 case wWhistle:
12361 case wWind:
12362 case wSSparkle:
12363 case wFSparkle:
12364 return 0;
12365
12366 case wLitBomb:
12367 case wLitSBomb:
12368
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12369 690 return 0;
12370
12371 113 clk2=96;
12372 113 misc=power;
12373
12374
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12375 3 item_set=isSBOMB100;
12376
12377 113 return 1;
12378
12379 case wBomb:
12380 case wSBomb:
12381
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12382 516 return 0;
12383
12384 975 stunclk=160;
12385 975 misc=wpnId; // store wpnId
12386 975 return 1;
12387
12388 case wSword:
12389
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12390 {
12391 88 sfx(WAV_EHIT,pan(int32_t(x)));
12392 88 hp=0;
12393 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12394 88 fading=0; // don't flash
12395 88 return 1;
12396 }
12397
12398 [[fallthrough]];
12399 default:
12400 75 sfx(WAV_CHINK,pan(int32_t(x)));
12401 75 }
12402
12403 75 return 1;
12404 8218 }
12405
12406 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12407 48 {
12408 48 fading=fade_flash_die;
12409 //nets+5180;
12410 48 previous_dir=-1;
12411
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12412 {
12413 1 dir=up;
12414 1 }
12415
12416
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12417 {
12418 dir=left;
12419 }
12420
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12421 48 }
12422
12423 39398 bool eDodongo2::animate(int32_t index)
12424 {
12425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12426
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12427 {
12428 1158 return Dead(index);
12429 }
12430
12431
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12432 {
12433 167 removearmos(x,y,ffcactivated);
12434 167 }
12435
12436
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12437 {
12438
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12439 42 hp-=misc; // store bomb's power in misc
12440 4032 }
12441 else
12442 34208 constant_walk(rate,homing,spw_clipbottomright);
12443
12444 38240 hit_width = (dir<=down) ? 16 : 32;
12445 38240 hit_height = (dir>=left) ? 16 : 32;
12446 38240 hxofs=(dir>=left)?-8:0;
12447 38240 hyofs=(dir<left)?-8:0;
12448
12449 38240 return enemy::animate(index);
12450 39398 }
12451
12452 39601 void eDodongo2::draw(BITMAP *dest)
12453 {
12454
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12455 {
12456 768 enemy::drawzcboss(dest);
12457 768 return;
12458 }
12459
12460 38833 int32_t tempx=xofs;
12461 38833 int32_t tempy=yofs;
12462 38833 update_enemy_frame();
12463 38833 enemy::drawzcboss(dest);
12464 38833 tile+=dummy_int[1]; //second tile change
12465 38833 xofs+=dummy_int[2]; //new xofs change
12466 38833 yofs+=dummy_int[3]; //new yofs change
12467 38833 enemy::drawzcboss(dest);
12468 38833 xofs=tempx;
12469 38833 yofs=tempy;
12470 39601 }
12471
12472 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12473 {
12474 3929 int32_t wpnId = w->id;
12475 3929 int32_t power = w->power;
12476 3929 int32_t wpnx = w->x;
12477 3929 int32_t wpny = w->y;
12478
12479
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12480 2377 return 0;
12481
12482
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12483 {
12484 case wPhantom:
12485 return 0;
12486
12487 case wFire:
12488 case wBait:
12489 case wWhistle:
12490 case wWind:
12491 case wSSparkle:
12492 case wFSparkle:
12493 346 return 0;
12494
12495 case wLitBomb:
12496 case wLitSBomb:
12497
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12498 {
12499 case up:
12500
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12501 77 return 0;
12502
12503 4 break;
12504
12505 case down:
12506
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12507 71 return 0;
12508
12509 6 break;
12510
12511 case left:
12512
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12513 66 return 0;
12514
12515 16 break;
12516
12517 case right:
12518
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12519 65 return 0;
12520
12521 16 break;
12522 }
12523
12524 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12525 // return 0;
12526 42 clk2=96;
12527 42 misc=power;
12528
12529
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12530 item_set=isSBOMB100;
12531
12532 42 return 1;
12533
12534 case wBomb:
12535 case wSBomb:
12536
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12537 {
12538 case up:
12539
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12540 84 return 0;
12541
12542 92 break;
12543
12544 case down:
12545
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12546 113 return 0;
12547
12548 55 break;
12549
12550 case left:
12551
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12552 80 return 0;
12553
12554 105 break;
12555
12556 case right:
12557
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12558 71 return 0;
12559
12560 93 break;
12561 }
12562
12563 345 stunclk=160;
12564 345 misc=wpnId; // store wpnId
12565 345 return 1;
12566
12567 case wSword:
12568
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12569 {
12570 34 sfx(WAV_EHIT,pan(int32_t(x)));
12571 34 hp=0;
12572 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12573 34 fading=0; // don't flash
12574 34 return 1;
12575 }
12576
12577 [[fallthrough]];
12578 default:
12579 158 sfx(WAV_CHINK,pan(int32_t(x)));
12580 158 }
12581
12582 158 return 1;
12583 3929 }
12584
12585 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12586 126 {
12587 //these are here to bypass compiler warnings about unused arguments
12588
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if ( !(editorflags & ENEMY_FLAG5) )
12589 {
12590
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 x = dmisc1 ? 64 : 176;
12591
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 y = 64;
12592 126 }
12593 else { x = X; y = Y; }
12594
12595 //nets+5940;
12596
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 45 times.
126 if(get_qr(qr_NEWENEMYTILES))
12597 {
12598 81 }
12599 else
12600 {
12601
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 7 times.
45 if(dmisc1)
12602 {
12603 7 flip=1;
12604 7 }
12605 }
12606
12607
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
126 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12608 126 clk3=32;
12609 126 clk2=0;
12610 126 clk4=clk;
12611 126 dir=left;
12612
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
126 if (SIZEflags != 0) init_size_flags();;
12613 126 }
12614
12615 71899 bool eAquamentus::animate(int32_t index)
12616 {
12617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71899 times.
71899 if(switch_hooked) return enemy::animate(index);
12618
2/2
✓ Branch 0 taken 2092 times.
✓ Branch 1 taken 69807 times.
71899 if(dying)
12619 2092 return Dead(index);
12620
12621 // fbx=x+((id==eRAQUAM)?4:-4);
12622
2/2
✓ Branch 0 taken 69490 times.
✓ Branch 1 taken 317 times.
69807 if(clk==0)
12623 {
12624 317 removearmos(x,y,ffcactivated);
12625 317 }
12626
12627 69807 fbx=x;
12628
12629 /*
12630 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12631 {
12632 fbx+=16;
12633 }
12634 */
12635
2/2
✓ Branch 0 taken 69357 times.
✓ Branch 1 taken 450 times.
69807 if(--clk3==0)
12636 {
12637 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12638 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12639 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12640 450 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12641 450 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12642 450 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12643 450 sfx(wpnsfx(wpn),pan(int32_t(x)));
12644 450 }
12645
12646
4/4
✓ Branch 0 taken 21363 times.
✓ Branch 1 taken 48444 times.
✓ Branch 2 taken 345 times.
✓ Branch 3 taken 21018 times.
69807 if(clk3<-80 && !(zc_oldrand()&63))
12647 {
12648 345 clk3=32;
12649 345 }
12650
12651
2/2
✓ Branch 0 taken 68690 times.
✓ Branch 1 taken 1117 times.
69807 if(!((clk4+1)&63))
12652 {
12653 1117 int32_t d2=(zc_oldrand()%3)+1;
12654
12655
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 752 times.
1117 if(d2>=left)
12656 {
12657 752 dir=d2;
12658 752 }
12659
12660
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 732 times.
1117 if(dmisc1)
12661 {
12662
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(x<=40)
12663 {
12664 38 dir=right;
12665 38 }
12666
12667
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(x>=104)
12668 {
12669 dir=left;
12670 }
12671 385 }
12672 else
12673 {
12674
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 21 times.
732 if(x<=136)
12675 {
12676 21 dir=right;
12677 21 }
12678
12679
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 34 times.
732 if(x>=200)
12680 {
12681 34 dir=left;
12682 34 }
12683 }
12684 1117 }
12685
12686
4/4
✓ Branch 0 taken 67907 times.
✓ Branch 1 taken 1900 times.
✓ Branch 2 taken 59366 times.
✓ Branch 3 taken 8541 times.
69807 if(clk4>=-1 && !((clk4+1)&7))
12687 {
12688
2/2
✓ Branch 0 taken 4546 times.
✓ Branch 1 taken 3995 times.
8541 if(dir==left)
12689 {
12690 4546 x-=1;
12691 4546 }
12692 else
12693 {
12694 3995 x+=1;
12695 }
12696 8541 }
12697
12698 69807 clk4=(clk4+1)%256;
12699
12700 69807 return enemy::animate(index);
12701 71899 }
12702
12703 72310 void eAquamentus::draw(BITMAP *dest)
12704 {
12705
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 27316 times.
72310 if(get_qr(qr_NEWENEMYTILES))
12706 {
12707 44994 xofs=(dmisc1?-16:0);
12708
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12709
12710
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12711 {
12712 1312 xofs=0;
12713 1312 enemy::draw(dest);
12714 1312 }
12715 else
12716 {
12717 43682 drawblock(dest,15);
12718 }
12719 44994 }
12720 else
12721 {
12722 27316 int32_t xblockofs=((dmisc1)?-16:16);
12723 27316 xofs=0;
12724
12725
4/4
✓ Branch 0 taken 26634 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 780 times.
✓ Branch 3 taken 25854 times.
27316 if(clk<0 || dying)
12726 {
12727 1462 enemy::draw(dest);
12728 1462 return;
12729 }
12730
1/2
✓ Branch 0 taken 25854 times.
✗ Branch 1 not taken.
25854 if ( do_animation )
12731 {
12732 // face (0=firing, 2=resting)
12733 25854 tile=o_tile+((clk3>0)?0:2);
12734 25854 enemy::draw(dest);
12735 // tail (
12736 25854 tile=o_tile+((clk&16)?1:3);
12737 25854 xofs=xblockofs;
12738 25854 enemy::draw(dest);
12739 // body
12740 25854 yofs+=16;
12741 25854 xofs=0;
12742 25854 tile=o_tile+((clk&16)?20:22);
12743 25854 enemy::draw(dest);
12744 25854 xofs=xblockofs;
12745 25854 tile=o_tile+((clk&16)?21:23);
12746 25854 enemy::draw(dest);
12747 25854 yofs-=16;
12748 25854 }
12749 else enemy::draw(dest);
12750 }
12751 72310 }
12752
12753 23834 bool eAquamentus::hit(weapon *w)
12754 {
12755
3/6
✓ Branch 0 taken 23834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23834 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23834 times.
23834 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12756
12757
2/2
✓ Branch 0 taken 4201 times.
✓ Branch 1 taken 19633 times.
23834 switch(w->id)
12758 {
12759 case wBeam:
12760 case wRefBeam:
12761 case wMagic:
12762 4201 hit_height=32;
12763 4201 }
12764
12765
4/4
✓ Branch 0 taken 22740 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17546 times.
✓ Branch 3 taken 5194 times.
23834 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12766 23834 hit_height=16;
12767 23834 return ret;
12768
12769 23834 }
12770
12771 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12772 93 {
12773
12774
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12775 {
12776
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 x = 128;
12777
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 y = 48;
12778 93 }
12779 else { x = X; y = Y; }
12780
12781 93 Clk=Clk;
12782
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12783 {
12784 clk=0;
12785 superman = 1;
12786 fading=fade_flicker;
12787 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12788 }
12789
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12790 {
12791 42 clk=0;
12792 42 }
12793 93 hxofs=-16;
12794 93 hit_width=48;
12795 93 clk4=0;
12796
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12797
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12798
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12799
12800 //nets+5340;
12801 93 }
12802
12803 70891 bool eGohma::animate(int32_t index)
12804 {
12805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12806
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12807 1226 return Dead(index);
12808
12809
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12810 {
12811
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12812 {
12813 35 clk4=0;
12814 35 superman=0;
12815 35 fading=0;
12816 35 clk=0;
12817
12818 35 }
12819 1 else return enemy::animate(index);
12820 35 }
12821
12822
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12823 {
12824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if (ffcactivated) removearmosffc(ffcactivated-1);
12825 else
12826 {
12827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12828 350 did_armos = false;
12829 350 removearmos(x,y);
12830 350 did_armos = false;
12831
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12832 }
12833 350 }
12834
12835
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12836
12837 // Movement clk must be separate from animation clk because of the Clock item
12838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12839 68878 clk4++;
12840
12841
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12842 {
12843
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12844 546 dir^=1;
12845 else
12846 486 dir=zc_oldrand()%3+1;
12847 1032 }
12848
12849
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12850 {
12851
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12852 {
12853 case 1:
12854 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12855 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12856 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12857 235 sfx(wpnsfx(wpn),pan(int32_t(x)));
12858 235 break;
12859
12860 default:
12861
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12862 {
12863 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12864 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12865 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12866 754 }
12867
12868 882 break;
12869 }
12870 1117 }
12871
12872
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12873 {
12874
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12875 {
12876 290 FireBreath(true);
12877 290 }
12878 2215 }
12879
12880
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12881 34479 move((zfix)1);
12882
12883
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12884 150 clk3=0;
12885
12886 68878 return enemy::animate(index);
12887 70891 }
12888
12889 70889 void eGohma::draw(BITMAP *dest)
12890 {
12891 70889 tile=o_tile;
12892
12893
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12894 {
12895 2012 enemy::drawzcboss(dest);
12896 2012 return;
12897 }
12898
12899
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12900 {
12901 ///if ( do_animation )
12902 //Yuck. Gohma can just not have this capability right now.
12903 // left side
12904 53472 xofs=-16;
12905 53472 flip=0;
12906 // if(clk&16) tile=180;
12907 // else { tile=182; flip=1; }
12908 53472 tile+=(3*((clk&48)>>4));
12909 53472 enemy::drawzcboss(dest);
12910
12911 // right side
12912 53472 xofs=16;
12913 // tile=(180+182)-tile;
12914 53472 tile=o_tile;
12915 53472 tile+=(3*((clk&48)>>4))+2;
12916 53472 enemy::drawzcboss(dest);
12917
12918 // body
12919 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12920 53472 tile=o_tile;
12921
12922 // tile+=(3*((clk&24)>>3))+2;
12923
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12924 2975 tile+=7;
12925
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12926 15890 tile+=10;
12927
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12928 2051 tile+=7;
12929 else
12930 32556 tile+=((clk3-132)&24)?4:1;
12931
12932 53472 enemy::drawzcboss(dest);
12933
12934 53472 }
12935 else
12936 {
12937 // left side
12938 15405 xofs=-16;
12939 15405 flip=0;
12940
12941
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12942 {
12943 7790 tile+=2;
12944 7790 flip=1;
12945 7790 }
12946
12947 15405 enemy::draw(dest);
12948
12949 // right side
12950 15405 tile=o_tile;
12951 15405 xofs=16;
12952
12953
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12954
12955 // tile=(180+182)-tile;
12956 15405 enemy::draw(dest);
12957
12958 // body
12959 15405 tile=o_tile;
12960 15405 xofs=0;
12961
12962
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
12963 912 tile+=4;
12964
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
12965 4882 tile+=5;
12966
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
12967 585 tile+=4;
12968 9026 else tile+=((clk3-132)&8)?3:1;
12969
12970 15405 enemy::draw(dest);
12971
12972 }
12973 70889 }
12974
12975 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
12976 {
12977 578 int32_t wpnId = w->id;
12978 578 int32_t power = w->power;
12979 578 int32_t wpnx = w->x;
12980 578 int32_t wpnDir = w->dir;
12981 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
12982
12983
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
12984 {
12985
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
12986 {
12987 93 sfx(WAV_CHINK,pan(int32_t(x)));
12988 93 return 1;
12989 }
12990 328 }
12991
12992 485 return enemy::takehit(w, realweap);
12993 578 }
12994
12995 327 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12996 327 {
12997 327 count_enemy=(id==(id&0xFFF));
12998 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
12999
1/4
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327 if (SIZEflags != 0) init_size_flags();;
13000 327 }
13001
13002 124050 bool eLilDig::animate(int32_t index)
13003 {
13004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124050 times.
124050 if(switch_hooked) return enemy::animate(index);
13005
2/2
✓ Branch 0 taken 4410 times.
✓ Branch 1 taken 119640 times.
124050 if(dying)
13006 4410 return Dead(index);
13007
13008
2/2
✓ Branch 0 taken 7105 times.
✓ Branch 1 taken 112535 times.
119640 if(clk==0)
13009 {
13010 7105 removearmos(x,y,ffcactivated);
13011 7105 }
13012
13013
2/2
✓ Branch 0 taken 80994 times.
✓ Branch 1 taken 38646 times.
119640 if(misc<=128)
13014 {
13015
2/2
✓ Branch 0 taken 1161 times.
✓ Branch 1 taken 37485 times.
38646 if(!(++misc&31))
13016 1161 step+=0.25;
13017 38646 }
13018
13019 119640 variable_walk_8(rate,homing,hrate,spw_floater);
13020 119640 return enemy::animate(index);
13021 124050 }
13022
13023 124268 void eLilDig::draw(BITMAP *dest)
13024 {
13025 124268 tile = o_tile;
13026 // tile = 160;
13027 124268 int32_t fdiv = frate/4;
13028
1/2
✓ Branch 0 taken 124268 times.
✗ Branch 1 not taken.
124268 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13029
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13030 124268 efrate:((clk>=(frate>>1))?1:0);
13031
13032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124268 times.
124268 if ( do_animation )
13033 {
13034
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 32811 times.
124268 if(get_qr(qr_NEWENEMYTILES))
13035 {
13036
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13037 {
13038 case up: //u
13039 11370 flip=0;
13040 11370 break;
13041
13042 case l_up: //d
13043 10699 flip=0;
13044 10699 tile+=4;
13045 10699 break;
13046
13047 case l_down: //l
13048 10722 flip=0;
13049 10722 tile+=8;
13050 10722 break;
13051
13052 case left: //r
13053 12015 flip=0;
13054 12015 tile+=12;
13055 12015 break;
13056
13057 case r_down: //ul
13058 10070 flip=0;
13059 10070 tile+=20;
13060 10070 break;
13061
13062 case down: //ur
13063 9554 flip=0;
13064 9554 tile+=24;
13065 9554 break;
13066
13067 case r_up: //dl
13068 8255 flip=0;
13069 8255 tile+=28;
13070 8255 break;
13071
13072 case right: //dr
13073 10033 flip=0;
13074 10033 tile+=32;
13075 10033 break;
13076 }
13077
13078 91457 tile+=f2;
13079 91457 }
13080 else
13081 {
13082 32811 tile+=(clk>=6)?1:0;
13083 }
13084 124268 }
13085
13086 124268 enemy::draw(dest);
13087 124268 }
13088
13089 80 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13090 80 {
13091
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 init_size_flags();
13092 80 }
13093
13094 29662 bool eBigDig::animate(int32_t index)
13095 {
13096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(switch_hooked) return enemy::animate(index);
13097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29662 times.
29662 if(dying)
13098 return Dead(index);
13099
13100
2/2
✓ Branch 0 taken 25558 times.
✓ Branch 1 taken 4104 times.
29662 if(clk==0)
13101 {
13102 4104 removearmos(x,y,ffcactivated);
13103 4104 }
13104
13105
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29534 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
29662 switch(misc)
13106 {
13107 case 0:
13108 29534 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13109 29534 break;
13110
13111 case 1:
13112 64 ++misc;
13113 64 break;
13114
13115 case 2:
13116
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 64 times.
175 for(int32_t i=0; i<dmisc5; i++)
13117 {
13118 111 addenemy(x,y,dmisc1+0x1000,-15);
13119 111 }
13120
13121
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc6; i++)
13122 {
13123 30 addenemy(x,y,dmisc2+0x1000,-15);
13124 30 }
13125
13126
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc7; i++)
13127 {
13128 30 addenemy(x,y,dmisc3+0x1000,-15);
13129 30 }
13130
13131
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 64 times.
94 for(int32_t i=0; i<dmisc8; i++)
13132 {
13133 30 addenemy(x,y,dmisc4+0x1000,-15);
13134 30 }
13135
13136
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
64 if(itemguy) // Hand down the carried item
13137 {
13138 2 guycarryingitem = guys.Count()-1;
13139 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13140 2 itemguy = false;
13141 2 }
13142
13143 64 stop_bgsfx(index);
13144
13145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13146
13147 64 return true;
13148 }
13149
13150 29598 return enemy::animate(index);
13151 29662 }
13152
13153 29658 void eBigDig::draw(BITMAP *dest)
13154 {
13155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if(anim!=aDIG)
13156 {
13157 update_enemy_frame();
13158 xofs-=8;
13159 yofs-=8;
13160 drawblock(dest,15);
13161 xofs+=8;
13162 yofs+=8;
13163 return;
13164 }
13165
13166 29658 tile = o_tile;
13167 29658 int32_t fdiv = frate/4;
13168
1/2
✓ Branch 0 taken 29658 times.
✗ Branch 1 not taken.
29658 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13169
13170
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13171 29658 efrate:((clk>=(frate>>1))?1:0);
13172
13173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29658 times.
29658 if ( do_animation )
13174 {
13175
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13497 times.
29658 if(get_qr(qr_NEWENEMYTILES))
13176 {
13177
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13178 {
13179 case up: //u
13180 1688 flip=0;
13181 1688 break;
13182
13183 case l_up: //d
13184 1684 flip=0;
13185 1684 tile+=8;
13186 1684 break;
13187
13188 case l_down: //l
13189 2031 flip=0;
13190 2031 tile+=40;
13191 2031 break;
13192
13193 case left: //r
13194 1910 flip=0;
13195 1910 tile+=48;
13196 1910 break;
13197
13198 case r_down: //ul
13199 2041 flip=0;
13200 2041 tile+=80;
13201 2041 break;
13202
13203 case down: //ur
13204 2043 flip=0;
13205 2043 tile+=88;
13206
13207 2043 break;
13208
13209 case r_up: //dl
13210 1514 flip=0;
13211 1514 tile+=120;
13212 1514 break;
13213
13214 case right: //dr
13215 2241 flip=0;
13216 2241 tile+=128;
13217 2241 break;
13218 }
13219
13220 16161 tile+=(f2*2);
13221 16161 }
13222 else
13223 {
13224 13497 tile+=(f2)?0:2;
13225 13497 flip=(clk&1)?1:0;
13226 }
13227 29658 }
13228
13229 29658 xofs-=8;
13230 29658 yofs-=8;
13231 29658 drawblock(dest,15);
13232 29658 xofs+=8;
13233 29658 yofs+=8;
13234 29658 }
13235
13236 869 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13237 {
13238 869 int32_t wpnId = w->id;
13239
13240
3/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
869 if(wpnId==wWhistle && misc==0)
13241 64 misc=1;
13242
13243 869 return 0;
13244 }
13245
13246 80 void eBigDig::init_size_flags()
13247 {
13248 80 SIZEflags = d->SIZEflags;
13249
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13250 // al_trace("Enemy txsz:%i\n", txsz);
13251
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
80 if (((SIZEflags & guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13252
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13253 80 else hit_width = 32;
13254
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13255 80 else hit_height = 32;
13256
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
80 if (((SIZEflags & guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13257 80 else hzsz = 16; // hard to jump.
13258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13259 80 else hxofs = -8;
13260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if ((SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13261 80 else hyofs = -8;
13262 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13263
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & guyflagOVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13264
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & guyflagOVERRIDE_DRAW_Y_OFFSET) != 0)
13265 {
13266 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13267 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13268 }
13269
13270
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if ((SIZEflags & guyflagOVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13271 80 }
13272
13273 /*
13274 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13275 {
13276 hxofs=hyofs=8;
13277 hzsz=16; //can't be jumped.
13278 clk2=70;
13279 misc=-1;
13280 mainguy=!getmapflag();
13281 }
13282
13283 bool eGanon::animate(int32_t index)
13284 {
13285 if(switch_hooked) return enemy::animate(index);
13286 if(dying)
13287
13288 return Dead(index);
13289
13290 if(clk==0)
13291 {
13292 removearmos(x,y,ffcactivated);
13293 }
13294
13295 switch(misc)
13296 {
13297 case -1:
13298 misc=0;
13299
13300 case 0:
13301 if(++clk2>72 && !(zc_oldrand()&3))
13302 {
13303 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
13304 sfx(wpnsfx(wpn),pan(int32_t(x)));
13305 clk2=0;
13306 }
13307
13308 Stunclk=0;
13309 constant_walk(rate,homing,spw_none);
13310 break;
13311
13312 case 1:
13313 case 2:
13314 if(--Stunclk<=0)
13315 {
13316 int32_t r=zc_oldrand();
13317
13318 if(r&1)
13319 {
13320 y=96;
13321
13322 if(r&2)
13323 x=160;
13324 else
13325 x=48;
13326
13327 if(tooclose(x,y,48))
13328 x=208-x;
13329 }
13330
13331 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
13332 //{
13333 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13334 // }
13335 // else
13336 // {
13337 loadpalset(csBOSS,pSprite(d->bosspal));
13338 // }
13339 misc=0;
13340 }
13341
13342 break;
13343
13344 case 3:
13345 {
13346 if(hclk>0)
13347 break;
13348
13349 misc=4;
13350 clk=0;
13351 hxofs=1000;
13352 loadpalset(9,pSprite(spPILE));
13353 music_stop();
13354 stop_sfx(WAV_ROAR);
13355
13356 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13357
13358 sfx(WAV_GANON);
13359 //Ganon's dustpile; fall in sideview. -Z
13360 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13361 dustpile->linked_parent = eeGANON;
13362 setmapflag();
13363 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13364 break;
13365 }
13366
13367 case 4:
13368 if(clk>=80)
13369 {
13370 misc=5;
13371
13372 if(getmapflag())
13373 {
13374 game->lvlitems[dlevel]|=liBOSS;
13375 //play_DmapMusic();
13376 playLevelMusic();
13377 return true;
13378 }
13379
13380 sfx(WAV_CLEARED);
13381 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
13382 setmapflag();
13383 }
13384
13385 break;
13386 }
13387
13388 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
13389 //{
13390 //if ( current_item_id(itype_amulet,false) >= 2 )
13391 //{
13392 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13393 //}
13394 //}
13395
13396
13397 return enemy::animate(index);
13398 }
13399
13400
13401 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13402 {
13403 //these are here to bypass compiler warnings about unused arguments
13404 int32_t wpnId = w->id;
13405 int32_t power = w->power;
13406 int32_t enemyHitWeapon = w->parentitem;
13407
13408 switch(misc)
13409 {
13410 case 0:
13411 {
13412 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
13413 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
13414 return 0;
13415
13416 //if we are not using the new defences, just reduce his HP
13417 if (!(editorflags & ENEMY_FLAG14))
13418 {
13419 hp-=power;
13420 if(hp>0)
13421 {
13422 misc=1;
13423 Stunclk=64;
13424 }
13425 else
13426 {
13427 loadpalset(csBOSS,pSprite(spBROWN));
13428 misc=2;
13429 Stunclk=284;
13430 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13431 }
13432
13433 sfx(WAV_EHIT,pan(int32_t(x)));
13434
13435 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13436
13437 return 1;
13438 }
13439 //otherwise, resolve his defence.
13440 else
13441 {
13442 int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage.
13443 if(hp>0)
13444 {
13445 misc=1;
13446 Stunclk=64;
13447 }
13448 else
13449 {
13450 loadpalset(csBOSS,pSprite(spBROWN));
13451 misc=2;
13452 Stunclk=284;
13453 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13454 }
13455
13456 sfx(WAV_EHIT,pan(int32_t(x)));
13457
13458 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13459
13460
13461 return 1;
13462 }
13463 }
13464 case 2:
13465 {
13466 if
13467 (
13468 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
13469 || //or nothing specified, use silver arrows+
13470 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
13471 )
13472 return 0;
13473 {
13474 misc=3;
13475 hclk=81;
13476 loadpalset(9,pSprite(spBROWN));
13477 return 1;
13478 }
13479
13480 }
13481 }
13482
13483 return 0;
13484 }
13485
13486 void eGanon::draw(BITMAP *dest)
13487 {
13488 switch(misc)
13489 {
13490 case 0:
13491 if((clk&3)==3)
13492 tile=(zc_oldrand()%5)*2+o_tile;
13493
13494 if(db!=999)
13495 break;
13496
13497 case 2:
13498 if(Stunclk<64 && (Stunclk&1) )
13499 {
13500 if
13501 (
13502 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13503 ||
13504 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13505 )
13506 {
13507 goto ganon_draw; //draw his weapons if we can see him
13508 }
13509 break;
13510 }
13511
13512 case -1:
13513 tile=o_tile;
13514
13515 //fall through
13516 case 1:
13517 case 3:
13518 ganon_draw:
13519 drawblock(dest,15);
13520 break;
13521
13522 case 4:
13523 draw_guts(dest);
13524 draw_flash(dest);
13525 break;
13526 }
13527
13528 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
13529 {
13530 if
13531 (
13532 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13533 ||
13534 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13535 )
13536 {
13537 draw_guts(dest); //makes his shots visible, but not him
13538 draw_flash(dest);
13539 }
13540 }
13541 }
13542
13543 void eGanon::draw_guts(BITMAP *dest)
13544 {
13545 int32_t c = zc_min(clk>>3,8);
13546 tile = clk<24 ? 74 : 75;
13547 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
13548 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
13549 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
13550 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
13551 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
13552 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
13553 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
13554 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
13555 }
13556
13557 void eGanon::draw_flash(BITMAP *dest)
13558 {
13559
13560 int32_t c = clk-(clk>>2);
13561 cs = (frame&3)+6;
13562 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
13563 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
13564 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
13565 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
13566 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
13567 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
13568 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
13569 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
13570 }
13571 */
13572
13573 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13574 13 {
13575 13 hxofs=hyofs=8;
13576
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13577 {
13578 hxofs = 4;
13579 hyofs = 4;
13580 hit_width = 24;
13581 hit_height = 24;
13582 SIZEflags|=guyflagOVERRIDE_HIT_WIDTH;
13583 SIZEflags|=guyflagOVERRIDE_HIT_HEIGHT;
13584 }
13585 13 hzsz=16; //can't be jumped.
13586 13 clk2=70;
13587 13 misc=-1;
13588
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
13589 13 }
13590
13591 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13592 {
13593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13594
13595 return Dead(index);
13596
13597
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13598 {
13599 72 removearmos(x,y,ffcactivated);
13600 72 }
13601
13602
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13603 {
13604 case -1:
13605 13 misc=0;
13606 [[fallthrough]];
13607 case 0:
13608
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13609 {
13610 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13611 173 sfx(wpnsfx(wpn),pan(int32_t(x)));
13612 173 clk2=0;
13613 173 }
13614
13615 12693 Stunclk=0;
13616 12693 constant_walk(rate,homing,spw_none);
13617 12693 break;
13618
13619 case 1:
13620 case 2:
13621
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13622 {
13623 41 int32_t r=zc_oldrand();
13624
13625
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13626 {
13627 17 y=96;
13628
13629
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13630 6 x=160;
13631 else
13632 11 x=48;
13633
13634
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13635 8 x=208-x;
13636 17 }
13637
13638 41 loadpalset(csBOSS,pSprite(d->bosspal));
13639 41 misc=0;
13640 41 }
13641
13642 3607 break;
13643
13644 case 3:
13645 {
13646
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13647 972 break;
13648
13649 12 misc=4;
13650 12 clk=0;
13651 12 hxofs=1000;
13652 12 loadpalset(9,pSprite(spPILE));
13653 12 music_stop();
13654 12 stop_sfx(WAV_ROAR);
13655
13656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13657
13658 12 sfx(WAV_GANON);
13659 //Ganon's dustpile; fall in sideview. -Z
13660 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13661 //dustpile->miscellaneous[31] = eeGANON;
13662
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13663 12 item *dustpile = NULL;
13664 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13665 12 dustpile = (item *)items.spr(items.Count() - 1);
13666 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13667 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
13668 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13669 12 break;
13670 }
13671
13672 case 4:
13673
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13674 {
13675 12 misc=5;
13676
13677 //game->lvlitems[dlevel]|=liBOSS;
13678
13679 12 sfx(WAV_CLEARED);
13680 //Add the big TF over the ashes!
13681
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13682 {
13683 24 item *ashes = (item*)items.spr(q);
13684
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13685 {
13686 //Z_scripterrlog("Found correct dustpile!\n");
13687
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13688 12 item *bigtriforce = NULL;
13689 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13690 12 bigtriforce->linked_parent = eeGANON;
13691 12 }
13692 24 }
13693 //setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13694 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
13695 12 }
13696
13697 960 break;
13698 10 case 5: return true;
13699 }
13700
13701 18244 return enemy::animate(index);
13702 18254 }
13703
13704
13705 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13706 {
13707 //these are here to bypass compiler warnings about unused arguments
13708 964 int32_t wpnId = w->id;
13709 964 int32_t power = w->power;
13710 964 int32_t enemyHitWeapon = w->parentitem;
13711
13712
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13713 {
13714 case 0:
13715
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13716 31 return 0;
13717
13718 53 hp-=power;
13719
13720
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13721 {
13722 41 misc=1;
13723 41 Stunclk=64;
13724 41 }
13725 else
13726 {
13727 12 loadpalset(csBOSS,pSprite(spBROWN));
13728 12 misc=2;
13729 12 Stunclk=284;
13730 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13731 }
13732
13733 53 sfx(WAV_EHIT,pan(int32_t(x)));
13734
13735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13736
13737 53 return 1;
13738
13739 case 2:
13740
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13741 154 return 0;
13742
13743 12 misc=3;
13744 12 hclk=81;
13745 12 loadpalset(9,pSprite(spBROWN));
13746 12 return 1;
13747 }
13748
13749 714 return 0;
13750 964 }
13751
13752 20776 void eGanon::draw(BITMAP *dest)
13753 {
13754
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13755 {
13756 case 0:
13757
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13758 3169 tile=(zc_oldrand()%5)*2+o_tile;
13759
13760
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13761 {
13762
13763 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13764 {
13765 int odraw = drawstyle;
13766 drawstyle = 2;
13767 drawblock(dest,15);
13768 drawstyle = odraw;
13769 }
13770 else
13771 {
13772 drawblock(dest,15);
13773 }
13774 break;
13775
13776 }
13777
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13778 {
13779 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13780 {
13781 int odraw = drawstyle;
13782 drawstyle = 2;
13783 drawblock(dest,15);
13784 drawstyle = odraw;
13785 }
13786 else
13787 {
13788 drawblock(dest,15);
13789 }
13790 break;
13791 }
13792
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13793 12680 break;
13794 [[fallthrough]];
13795 case 2:
13796
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13797 break;
13798 [[fallthrough]];
13799 case -1:
13800 3518 tile=o_tile;
13801
13802 [[fallthrough]];
13803 case 1:
13804 case 3:
13805 7126 drawblock(dest,15);
13806 7126 break;
13807
13808 case 4:
13809 960 draw_guts(dest);
13810 960 draw_flash(dest);
13811 960 break;
13812 }
13813 20776 }
13814
13815 960 void eGanon::draw_guts(BITMAP *dest)
13816 {
13817
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13818 960 tile = clk<24 ? 74 : 75;
13819 960 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
13820 960 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
13821 960 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
13822 960 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
13823 960 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
13824 960 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
13825 960 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
13826 960 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
13827 960 }
13828
13829 960 void eGanon::draw_flash(BITMAP *dest)
13830 {
13831
13832 960 int32_t c = clk-(clk>>2);
13833 960 cs = (frame&3)+6;
13834 960 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
13835 960 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
13836 960 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
13837 960 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
13838 960 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
13839 960 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
13840 960 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
13841 960 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
13842 960 }
13843
13844 15 void getBigTri(int32_t id2)
13845 {
13846 /*
13847 *************************
13848 * BIG TRIFORCE SEQUENCE *
13849 *************************
13850 0 BIGTRI out, WHITE flash in
13851 4 WHITE flash out, PILE cset white
13852 8 WHITE in
13853 ...
13854 188 WHITE out
13855 191 PILE cset red
13856 200 top SHUTTER opens
13857 209 bottom SHUTTER opens
13858 */
13859 15 sfx(itemsbuf[id2].playsound);
13860 15 guys.clear();
13861
13862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(itemsbuf[id2].flags & item_gamedata)
13863 {
13864 game->lvlitems[dlevel]|=liTRIFORCE;
13865 }
13866
13867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13868
13869 15 draw_screen(tmpscr);
13870
13871
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 2880 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2880 times.
2895 for(int32_t f=0; f<24*8 && !Quit; f++)
13872 {
13873
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==4)
13874 {
13875
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 15 times.
240 for(int32_t i=1; i<16; i++)
13876 {
13877 225 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13878 225 }
13879 15 }
13880
13881
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==0)
13882 {
13883
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 360 times.
1440 for(int32_t cs=2; cs<5; cs++)
13884 {
13885
2/2
✓ Branch 0 taken 16200 times.
✓ Branch 1 taken 1080 times.
17280 for(int32_t i=1; i<16; i++)
13886 {
13887 16200 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13888 16200 }
13889 1080 }
13890
13891 360 refreshpal=true;
13892 360 }
13893
13894
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 360 times.
2880 if((f&7)==4)
13895 {
13896
1/2
✓ Branch 0 taken 360 times.
✗ Branch 1 not taken.
360 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
13897 else loadlvlpal(0xB);
13898 360 }
13899
13900
2/2
✓ Branch 0 taken 2865 times.
✓ Branch 1 taken 15 times.
2880 if(f==191)
13901 {
13902 15 loadpalset(9,pSprite(spPILE));
13903 15 }
13904
13905 2880 advanceframe(true);
13906 2880 }
13907
13908 //play_DmapMusic();
13909 15 playLevelMusic();
13910
13911
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
15 if(itemsbuf[id2].flags & item_flag1 && currscr < 128)
13912 {
13913 2 Hero.dowarp(1,0); //side warp
13914 2 }
13915 15 }
13916
13917 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13918 618 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13919 618 {
13920
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if( !(editorflags & ENEMY_FLAG5) )
13921 {
13922
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 x=128;
13923
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 y=48;
13924 618 }
13925 //else { x = X; y = Y; }
13926
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 dir=(zc_oldrand()&7)+8;
13927 618 superman=1;
13928 618 fading=fade_invisible;
13929 618 hxofs=1000;
13930 618 segcnt=clk;
13931 618 segid=Id|0x1000;
13932 618 clk=0;
13933
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 id=guys.Count();
13934
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
618 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13935 618 tile=o_tile;
13936 618 hitdir = -1;
13937 618 stickclk = 0;
13938
13939 /*
13940 if (get_qr(qr_NEWENEMYTILES))
13941 {
13942 tile=nets+1220;
13943 }
13944 else
13945 {
13946 tile=57;
13947 }
13948 */
13949 618 }
13950
13951 244844 bool eMoldorm::animate(int32_t index)
13952 {
13953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(switch_hooked) return enemy::animate(index);
13954 244844 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
13955
2/2
✓ Branch 0 taken 216369 times.
✓ Branch 1 taken 28475 times.
244844 if ( y > (max_y) )
13956 {
13957 28475 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13958 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13959 28475 }
13960
2/2
✓ Branch 0 taken 244282 times.
✓ Branch 1 taken 562 times.
244844 if ( stickclk > 45 )
13961 {
13962 562 stickclk = 0;
13963 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13964 562 }
13965
13966
13967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244844 times.
244844 if(clk==0)
13968 {
13969 244844 removearmos(x,y,ffcactivated);
13970 244844 }
13971
13972
2/2
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 242393 times.
244844 if(clk2)
13973 {
13974
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 129 times.
2451 if(--clk2 == 0)
13975 {
13976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(flags&guy_never_return)
13977 129 never_return(index);
13978
13979
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
13980 129 leave_item();
13981
13982 129 stop_bgsfx(index);
13983 129 return true;
13984 }
13985 2322 }
13986 else
13987 {
13988
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(stunclk>0)
13989 stunclk=0;
13990 242393 constant_walk_8_old(rate,homing,spw_floater);
13991
13992
13993 242393 misc=dir;
13994
13995 // If any higher-numbered segments were killed, segcnt can be too high,
13996 // leading to a crash
13997
1/2
✓ Branch 0 taken 242393 times.
✗ Branch 1 not taken.
242393 if(index+segcnt>=guys.Count())
13998 segcnt=guys.Count()-index-1;
13999
14000
2/2
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 1122281 times.
1364674 for(int32_t i=index+1; i<index+segcnt+1; i++)
14001 {
14002 1122281 enemy* segment=((enemy*)guys.spr(i));
14003
14004 // More validation - if segcnt was wrong, this may not
14005 // actually be a Moldorm segment
14006
1/2
✓ Branch 0 taken 1122281 times.
✗ Branch 1 not taken.
1122281 if(segment->id!=segid)
14007 {
14008 segcnt=i-index-1;
14009 break;
14010 }
14011
14012
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1)
14013 {
14014 242669 x=segment->x;
14015 242669 y=segment->y;
14016 242669 }
14017
14018 1122281 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
14019 //Script your own blasted segmented bosses!! -Z
14020 1122281 segment->parent_script_UID = this->script_UID;
14021
4/4
✓ Branch 0 taken 242393 times.
✓ Branch 1 taken 879888 times.
✓ Branch 2 taken 24660 times.
✓ Branch 3 taken 217733 times.
1122281 if((i==index+segcnt)&&(i!=index+1)) //tail
14022 {
14023 217733 segment->dummy_int[1]=2;
14024 217733 }
14025 else
14026 {
14027 904548 segment->dummy_int[1]=1;
14028 }
14029
14030
2/2
✓ Branch 0 taken 879612 times.
✓ Branch 1 taken 242669 times.
1122281 if(i==index+1) //head
14031 {
14032 242669 segment->dummy_int[1]=0;
14033 242669 }
14034
14035
2/2
✓ Branch 0 taken 1121265 times.
✓ Branch 1 taken 1016 times.
1122281 if(segment->hp <= 0)
14036 {
14037 1016 int32_t offset=1;
14038
14039
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 1480 times.
2496 for(int32_t j=i; j<index+segcnt; j++)
14040 {
14041 // Triple-check
14042
1/2
✓ Branch 0 taken 1480 times.
✗ Branch 1 not taken.
1480 if(((enemy*)guys.spr(j+1))->id!=segid)
14043 {
14044 segcnt=j-index+1; // Add 1 because of --segcnt below
14045 break;
14046 }
14047 1480 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14048 1480 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14049 1480 }
14050
14051 1016 segment->hclk=33;
14052 1016 --segcnt;
14053 1016 --i; // Recheck the same index in case multiple segments died at once
14054 1016 }
14055 1122281 }
14056
14057
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 242264 times.
242393 if(segcnt==0)
14058 {
14059 129 clk2=19;
14060
14061 129 x=guys.spr(index+1)->x;
14062 129 y=guys.spr(index+1)->y;
14063 129 }
14064 }
14065
14066 244715 return false;
14067 244844 }
14068
14069 3150 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14070 3150 {
14071
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 if( !(editorflags & ENEMY_FLAG5) )
14072 {
14073
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 x=128;
14074
1/2
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
3150 y=48;
14075 3150 }
14076
14077
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3150 times.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14078 3150 hyofs=4;
14079 3150 hit_width=hit_height=8;
14080 3150 hxofs=1000;
14081 3150 mainguy=count_enemy=false;
14082 3150 parentclk = 0;
14083 3150 bgsfx=-1;
14084
2/4
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
3150 flags&=~guy_never_return;
14085 //deadsfx = WAV_EDEAD;
14086 3150 isCore = false;
14087 3150 }
14088
14089 1138024 bool esMoldorm::animate(int32_t index)
14090 {
14091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(switch_hooked) return enemy::animate(index);
14092 // Shouldn't be possible, but better to be sure
14093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1138024 times.
1138024 if(index==0)
14094 dying=true;
14095
14096
2/2
✓ Branch 0 taken 15743 times.
✓ Branch 1 taken 1122281 times.
1138024 if(dying)
14097 {
14098
1/2
✓ Branch 0 taken 15743 times.
✗ Branch 1 not taken.
15743 if(!dmisc2)
14099 15743 item_set=0;
14100
14101 15743 return Dead(index);
14102 }
14103
14104
2/2
✓ Branch 0 taken 105077 times.
✓ Branch 1 taken 1017204 times.
1122281 if(clk>=0)
14105 {
14106 1017204 hxofs=4;
14107 1017204 step=((enemy*)guys.spr(index-1))->step;
14108
14109
2/2
✓ Branch 0 taken 70455 times.
✓ Branch 1 taken 946749 times.
1017204 if(parentclk == 0)
14110 {
14111 70455 misc=dir;
14112 70455 dir=((enemy*)guys.spr(index-1))->misc;
14113 //do alignment, as in parent's animation :-/ -DD
14114 70455 x.doFloor();
14115 70455 y.doFloor();
14116 70455 }
14117
14118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(step)
14119 1017204 parentclk=(parentclk+1)%((int32_t)(8.0/step));
14120
14121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1017204 times.
1017204 if(!watch)
14122 {
14123 1017204 sprite::move(step);
14124 1017204 }
14125 1017204 }
14126
14127 1122281 return enemy::animate(index);
14128 1138024 }
14129
14130 2683 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
14131 {
14132
2/2
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 453 times.
2683 if(enemy::takehit(w,realweap))
14133 2230 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14134
14135 453 return 0;
14136 2683 }
14137
14138 1155313 void esMoldorm::draw(BITMAP *dest)
14139 {
14140 1155313 tile=o_tile;
14141 1155313 int32_t fdiv = frate/4;
14142
1/2
✓ Branch 0 taken 1155313 times.
✗ Branch 1 not taken.
1155313 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14143
14144
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 111383 times.
1155313 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14145 1155313 efrate:((clk>=(frate>>1))?1:0);
14146
14147
2/2
✓ Branch 0 taken 111383 times.
✓ Branch 1 taken 1043930 times.
1155313 if(get_qr(qr_NEWENEMYTILES))
14148 {
14149 1043930 tile+=dummy_int[1]*40;
14150
14151
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
14152 {
14153 102730 flip=0;
14154
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
14155
14156
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
14157 tile+=4;
14158 102730 }
14159 else
14160 {
14161
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
14162 {
14163 case up: //u
14164 96530 flip=0;
14165 96530 break;
14166
14167 case l_up: //d
14168 134534 flip=0;
14169 134534 tile+=4;
14170 134534 break;
14171
14172 case l_down: //l
14173 113426 flip=0;
14174 113426 tile+=8;
14175 113426 break;
14176
14177 case left: //r
14178 124800 flip=0;
14179 124800 tile+=12;
14180 124800 break;
14181
14182 case r_down: //ul
14183 101314 flip=0;
14184 101314 tile+=20;
14185 101314 break;
14186
14187 case down: //ur
14188 99043 flip=0;
14189 99043 tile+=24;
14190 99043 break;
14191
14192 case r_up: //dl
14193 131794 flip=0;
14194 131794 tile+=28;
14195 131794 break;
14196
14197 case right: //dr
14198 139759 flip=0;
14199 139759 tile+=32;
14200 139759 break;
14201 }
14202 }
14203
14204 1043930 tile+=f2;
14205 1043930 }
14206
14207
2/2
✓ Branch 0 taken 106267 times.
✓ Branch 1 taken 1049046 times.
1155313 if(clk>=0)
14208 1049046 enemy::draw(dest);
14209 1155313 }
14210
14211 420 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14212 420 {
14213
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 if( !(editorflags & ENEMY_FLAG5) )
14214 {
14215
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 x=64;
14216
1/2
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
420 y=80;
14217 420 }
14218 //else { x = X; y = Y; }
14219 //byte legaldirs = 0;
14220 420 int32_t incr = 16;
14221 //int32_t possiiblepos = 0;
14222 //int32_t positions[8] = {0};
14223
14224 //Don't spawn in pits.
14225
5/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 315 times.
✓ Branch 7 taken 105 times.
420 if ( m_walkflag_simple(x, y) )
14226 {
14227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
14228 {
14229 //move if we spawn over a pit
14230 //check each direction
14231
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14232 {
14233
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
14234 }
14235
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14236 {
14237
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
14238 }
14239
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14240 {
14241
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
14242 }
14243
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14244 {
14245
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
14246 }
14247
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14248 {
14249 y -= incr; break;
14250 }
14251
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14252 {
14253 y+=incr; break;
14254 }
14255
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14256 {
14257
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
14258 }
14259
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14260 {
14261 x+=incr; y+=incr; break;
14262 }
14263 34 else continue;
14264
14265 }
14266
14267 105 }
14268
14269 420 dir=up;
14270 420 superman=1;
14271 420 fading=fade_invisible;
14272 420 hxofs=1000;
14273 420 segcnt=clk;
14274 420 clk=0;
14275 //set up move history
14276
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 3060 times.
3480 for(int32_t i=0; i <= (1<<dmisc2); i++)
14277
3/6
✓ Branch 0 taken 3060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3060 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3060 times.
✗ Branch 5 not taken.
3060 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14278 420 }
14279
14280 236907 bool eLanmola::animate(int32_t index)
14281 {
14282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 236907 times.
236907 if(switch_hooked) return enemy::animate(index);
14283
2/2
✓ Branch 0 taken 196711 times.
✓ Branch 1 taken 40196 times.
236907 if(clk==0)
14284 {
14285 40196 removearmos(x,y,ffcactivated);
14286 40196 }
14287
14288
2/2
✓ Branch 0 taken 3591 times.
✓ Branch 1 taken 233316 times.
236907 if(clk2)
14289 {
14290
2/2
✓ Branch 0 taken 3402 times.
✓ Branch 1 taken 189 times.
3591 if(--clk2 == 0)
14291 {
14292
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 103 times.
189 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14293 86 leave_item();
14294
14295 189 stop_bgsfx(index);
14296 189 return true;
14297 }
14298
14299 3402 return false;
14300 }
14301
14302
14303 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14304 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14305 //I've added a complete movement history to this enemy to compensate -DD
14306 233316 constant_walk(rate,homing,spw_none);
14307 233316 prevState.pop_front();
14308 233316 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14309
14310 // This could cause a crash with Moldorms. I didn't see the same problem
14311 // with Lanmolas, but it looks like it ought to be possible, so here's
14312 // the same solution. - Saf
14313
1/2
✓ Branch 0 taken 233316 times.
✗ Branch 1 not taken.
233316 if(index+segcnt>=guys.Count())
14314 segcnt=guys.Count()-index-1;
14315
14316
2/2
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 966396 times.
1199712 for(int32_t i=index+1; i<index+segcnt+1; i++)
14317 {
14318 966396 enemy* segment=((enemy*)guys.spr(i));
14319
14320 // More validation in case segcnt is wrong
14321
1/2
✓ Branch 0 taken 966396 times.
✗ Branch 1 not taken.
966396 if((segment->id&0xFFF)!=(id&0xFFF))
14322 {
14323 segcnt=i-index-1;
14324 break;
14325 }
14326
14327 966396 segment->o_tile=o_tile;
14328 966396 segment->parent_script_UID = this->script_UID;
14329
4/4
✓ Branch 0 taken 233316 times.
✓ Branch 1 taken 733080 times.
✓ Branch 2 taken 37616 times.
✓ Branch 3 taken 195700 times.
966396 if((i==index+segcnt)&&(i!=index+1))
14330 {
14331 195700 segment->dummy_int[1]=1; //tail
14332 195700 }
14333 else
14334 {
14335 770696 segment->dummy_int[1]=0;
14336 }
14337
14338
2/2
✓ Branch 0 taken 965227 times.
✓ Branch 1 taken 1169 times.
966396 if(segment->hp <= 0)
14339 {
14340
2/2
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 1961 times.
3130 for(int32_t j=i; j<index+segcnt; j++)
14341 {
14342 // Triple-check
14343
1/2
✓ Branch 0 taken 1961 times.
✗ Branch 1 not taken.
1961 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14344 {
14345 segcnt=j-index+1; // Add 1 because of --segcnt below
14346 break;
14347 }
14348 1961 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14349 1961 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14350 1961 }
14351
14352 1169 ((enemy*)guys.spr(i))->hclk=33;
14353 1169 --segcnt;
14354 1169 --i; // Recheck the same index in case multiple segments died at once
14355 1169 }
14356 966396 }
14357
14358
2/2
✓ Branch 0 taken 233127 times.
✓ Branch 1 taken 189 times.
233316 if(segcnt==0)
14359 {
14360 189 clk2=19;
14361 189 x=guys.spr(index+1)->x;
14362 189 y=guys.spr(index+1)->y;
14363 189 setmapflag(mTMPNORET);
14364 189 }
14365
14366 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14367 //which is... disastrous.
14368 233316 hp = 1;
14369 233316 return enemy::animate(index);
14370 236907 }
14371
14372 2267 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14373 2267 {
14374
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 if( !(editorflags & ENEMY_FLAG5) )
14375 {
14376
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 x=64;
14377
1/2
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
2267 y=80;
14378 2267 }
14379 2267 int32_t incr = 16;
14380 //Don't spawn in pits.
14381
5/8
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2267 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1742 times.
✓ Branch 7 taken 525 times.
2267 if ( m_walkflag_simple(x, y) )
14382 {
14383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14384 {
14385 //move if we spawn over a pit
14386 //check each direction
14387
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14388 {
14389
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14390 }
14391
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14392 {
14393
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14394 }
14395
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14396 {
14397
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14398 }
14399
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14400 {
14401
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14402 }
14403
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14404 {
14405 y -= incr; break;
14406 }
14407
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14408 {
14409 y+=incr; break;
14410 }
14411
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14412 {
14413
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14414 }
14415
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14416 {
14417 x+=incr; y+=incr; break;
14418 }
14419 170 else continue;
14420
14421 }
14422
14423 525 }
14424
14425 2267 hxofs=1000;
14426 2267 hit_width=8;
14427 2267 mainguy=false;
14428 2267 count_enemy=(id<0x2000)?true:false;
14429
14430 //set up move history
14431
2/2
✓ Branch 0 taken 2267 times.
✓ Branch 1 taken 16763 times.
19030 for(int32_t i=0; i <= (1<<dmisc2); i++)
14432
3/6
✓ Branch 0 taken 16763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16763 times.
✗ Branch 5 not taken.
16763 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14433
14434 2267 bgsfx = -1;
14435 2267 isCore = false;
14436
2/4
✓ Branch 0 taken 2267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
2267 flags&=~guy_never_return;
14437 2267 }
14438
14439 985563 bool esLanmola::animate(int32_t index)
14440 {
14441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985563 times.
985563 if(switch_hooked) return enemy::animate(index);
14442 // Shouldn't be possible, but who knows
14443
2/2
✓ Branch 0 taken 985545 times.
✓ Branch 1 taken 18 times.
985563 if(index==0)
14444 18 dying=true;
14445
14446
2/2
✓ Branch 0 taken 19167 times.
✓ Branch 1 taken 966396 times.
985563 if(dying)
14447 {
14448 19167 xofs=0;
14449
14450
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9306 times.
19167 if(!dmisc3)
14451 9306 item_set=0;
14452
14453 19167 return Dead(index);
14454 }
14455
14456
2/2
✓ Branch 0 taken 35946 times.
✓ Branch 1 taken 930450 times.
966396 if(clk>=0)
14457 {
14458 930450 hxofs=4;
14459
14460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 930450 times.
930450 if(!watch)
14461 {
14462 930450 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14463 930450 prevState.pop_front();
14464 930450 prevState.push_back(newstate);
14465 930450 x = newstate.first.first;
14466 930450 y = newstate.first.second;
14467 930450 dir = newstate.second;
14468 930450 }
14469 930450 }
14470
14471 966396 return enemy::animate(index);
14472 985563 }
14473
14474 2655 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14475 {
14476
2/2
✓ Branch 0 taken 2065 times.
✓ Branch 1 taken 590 times.
2655 if(enemy::takehit(w,realweap))
14477 2065 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14478
14479 590 return 0;
14480 2655 }
14481
14482 990931 void esLanmola::draw(BITMAP *dest)
14483 {
14484 990931 tile=o_tile;
14485 990931 int32_t fdiv = frate/4;
14486
1/2
✓ Branch 0 taken 990931 times.
✗ Branch 1 not taken.
990931 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14487
14488
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14489 990931 efrate:((clk>=(frate>>1))?1:0);
14490
14491
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 361999 times.
990931 if(get_qr(qr_NEWENEMYTILES))
14492 {
14493
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14494 {
14495 481767 tile+=20;
14496
14497
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14498 {
14499 128742 tile+=20;
14500 128742 }
14501 481767 }
14502
14503
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14504 {
14505 case up:
14506 141419 flip=0;
14507 141419 break;
14508
14509 case down:
14510 140994 flip=0;
14511 140994 tile+=4;
14512 140994 break;
14513
14514 case left:
14515 159500 flip=0;
14516 159500 tile+=8;
14517 159500 break;
14518
14519 case right:
14520 187019 flip=0;
14521 187019 tile+=12;
14522 187019 break;
14523 }
14524
14525 628932 tile+=f2;
14526 628932 }
14527 else
14528 {
14529
2/2
✓ Branch 0 taken 90543 times.
✓ Branch 1 taken 271456 times.
361999 if(id>=0x2000)
14530 {
14531 271456 tile+=1;
14532 271456 }
14533 }
14534
14535
2/2
✓ Branch 0 taken 37038 times.
✓ Branch 1 taken 953893 times.
990931 if(clk>=0)
14536 953893 enemy::draw(dest);
14537 990931 }
14538
14539 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14540 150 {
14541 //these are here to bypass compiler warnings about unused arguments
14542 150 Clk=Clk;
14543 150 superman=1;
14544
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14545 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14546
14547
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14548 692 arm[i]=i;
14549
14550 150 fading=fade_blue_poof;
14551 //nets+4680;
14552 150 adjusted=false;
14553
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14554 150 }
14555
14556 66494 bool eManhandla::animate(int32_t index)
14557 {
14558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14559
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14560 1382 return Dead(index);
14561
14562
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14563 {
14564 2471 removearmos(x,y,ffcactivated);
14565 2471 }
14566
14567
14568 // check arm status, move dead ones to end of group
14569
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14570 {
14571 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14572
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14573 {
14574
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14575 {
14576 552 zc_swap(arm[j],arm[j+1]);
14577 552 guys.swap(index+j+1,index+j+2);
14578 552 }
14579
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14580 {
14581 87 leave_item();
14582 87 }
14583 424 --armcnt;
14584 424 --i;
14585 424 continue;
14586 }
14587
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14588 {
14589
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14590 {
14591 508 cur_arm->o_tile=o_tile+40;
14592 508 cur_arm->parent_script_UID = this->script_UID;
14593 508 }
14594 else
14595 {
14596 184 cur_arm->o_tile=o_tile+160;
14597 184 cur_arm->parent_script_UID = this->script_UID;
14598 }
14599 692 }
14600 193194 }
14601
14602 65112 adjusted=true;
14603
14604 // move or die
14605
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14606 83 hp=0;
14607 else
14608 {
14609 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14610
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14611
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14612 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14613
14614
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14615 {
14616
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14617 {
14618
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14619 {
14620 case 0:
14621 38579 dy1=-24;
14622 38579 break;
14623
14624 case 1:
14625 36328 dy2=31;
14626 36328 break;
14627
14628 case 2:
14629 36250 dx1=-16;
14630 36250 break;
14631
14632 case 3:
14633 39862 dx2=31;
14634 39862 break;
14635 }
14636 151019 }
14637 53584 }
14638 else
14639 {
14640 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14641
14642
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14643 {
14644
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14645 {
14646 case 0:
14647 12012 dy1=-32;
14648 12012 break;
14649
14650 case 1:
14651 7730 dy2=39;
14652 7730 break;
14653
14654 case 2:
14655 9837 dx1=-24;
14656 9837 break;
14657
14658 case 3:
14659 12596 dx2=39;
14660 12596 break;
14661 }
14662 42175 }
14663 }
14664
14665 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14666
14667
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14668 {
14669 193194 zfix dx=(zfix)0,dy=(zfix)0;
14670
14671
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14672 {
14673
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14674 {
14675 case 0:
14676 38579 dy=-16;
14677 38579 break;
14678
14679 case 1:
14680 36328 dy=16;
14681 36328 break;
14682
14683 case 2:
14684 36250 dx=-16;
14685 36250 break;
14686
14687 case 3:
14688 39862 dx=16;
14689 39862 break;
14690 }
14691 151019 }
14692 else
14693 {
14694
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14695 {
14696 case 0:
14697 5447 dy=-24;
14698 5447 dx=-8;
14699 5447 break;
14700
14701 case 1:
14702 3986 dy=24;
14703 3986 dx=8;
14704 3986 break;
14705
14706 case 2:
14707 4163 dx=-24;
14708 4163 dy=8;
14709 4163 break;
14710
14711 case 3:
14712 6774 dx=24;
14713 6774 dy=-8;
14714 6774 break;
14715
14716 case 4:
14717 6565 dy=-24;
14718 6565 dx=8;
14719 6565 break;
14720
14721 case 5:
14722 3744 dy=24;
14723 3744 dx=-8;
14724 3744 break;
14725
14726 case 6:
14727 5674 dx=-24;
14728 5674 dy=-8;
14729 5674 break;
14730
14731 case 7:
14732 5822 dx=24;
14733 5822 dy=8;
14734 5822 break;
14735 }
14736 }
14737
14738 193194 guys.spr(index+i+1)->x = x+dx;
14739 193194 guys.spr(index+i+1)->y = y+dy;
14740 193194 }
14741 }
14742
14743 65112 return enemy::animate(index);
14744 66494 }
14745
14746
14747 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14748 {
14749 1751 int32_t wpnId = w->id;
14750
14751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14752 return 0;
14753
14754
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14755 {
14756 case wBomb:
14757 case wSBomb:
14758 case wSword:
14759 case wHammer:
14760 case wWand:
14761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14762
14763 case wLitBomb:
14764 case wLitSBomb:
14765 case wBait:
14766 case wWhistle:
14767 case wFire:
14768 case wWind:
14769 case wSSparkle:
14770 case wFSparkle:
14771 case wPhantom:
14772 1709 return 0;
14773
14774 case wHookshot:
14775 case wBrang:
14776 sfx(WAV_CHINK,pan(int32_t(x)));
14777 break;
14778
14779 default:
14780
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14781 else sfx(WAV_CHINK,pan(int32_t(x)));
14782
14783 42 }
14784
14785 42 return 1;
14786 1751 }
14787
14788 66490 void eManhandla::draw(BITMAP *dest)
14789 {
14790 66490 tile=o_tile;
14791 66490 int32_t fdiv = frate/4;
14792
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14793
14794
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14795 66490 efrate:((clk>=(frate>>1))?1:0);
14796
14797
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14798 {
14799
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14800 {
14801
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14802 {
14803 case up: //u
14804 4771 flip=0;
14805 4771 break;
14806
14807 case l_up: //d
14808 4640 flip=0;
14809 4640 tile+=4;
14810 4640 break;
14811
14812 case l_down: //l
14813 4995 flip=0;
14814 4995 tile+=8;
14815 4995 break;
14816
14817 case left: //r
14818 5574 flip=0;
14819 5574 tile+=12;
14820 5574 break;
14821
14822 case r_down: //ul
14823 3793 flip=0;
14824 3793 tile+=20;
14825 3793 break;
14826
14827 case down: //ur
14828 3930 flip=0;
14829 3930 tile+=24;
14830 3930 break;
14831
14832 case r_up: //dl
14833 3908 flip=0;
14834 3908 tile+=28;
14835 3908 break;
14836
14837 case right: //dr
14838 5883 flip=0;
14839 5883 tile+=32;
14840 5883 break;
14841 }
14842
14843 37494 tile+=f2;
14844 37494 enemy::draw(dest);
14845 37494 } //manhandla 2, big body
14846 else
14847 {
14848
14849
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14850 {
14851 case up: //u
14852 1277 flip=0;
14853 1277 break;
14854
14855 case l_up: //d
14856 1360 flip=0;
14857 1360 tile+=8;
14858 1360 break;
14859
14860 case l_down: //l
14861 2242 flip=0;
14862 2242 tile+=40;
14863 2242 break;
14864
14865 case left: //r
14866 1789 flip=0;
14867 1789 tile+=48;
14868 1789 break;
14869
14870 case r_down: //ul
14871 1345 flip=0;
14872 1345 tile+=80;
14873 1345 break;
14874
14875 case down: //ur
14876 805 flip=0;
14877 805 tile+=88;
14878 805 break;
14879
14880 case r_up: //dl
14881 948 flip=0;
14882 948 tile+=120;
14883 948 break;
14884
14885 case right: //dr
14886 1542 flip=0;
14887 1542 tile+=128;
14888 1542 break;
14889 }
14890
14891 11308 tile+=(f2*2);
14892 11308 xofs-=8;
14893 11308 yofs-=8;
14894 11308 drawblock(dest,15);
14895 11308 xofs+=8;
14896 11308 yofs+=8;
14897 }
14898 48802 }
14899 else
14900 {
14901
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14902 {
14903 17173 enemy::draw(dest);
14904 17173 }
14905 else
14906 {
14907 515 xofs-=8;
14908 515 yofs-=8;
14909 515 enemy::draw(dest);
14910 515 xofs+=16;
14911 515 enemy::draw(dest);
14912 515 yofs+=16;
14913 515 enemy::draw(dest);
14914 515 xofs-=16;
14915 515 enemy::draw(dest);
14916 515 xofs+=8;
14917 515 yofs-=8;
14918 }
14919 }
14920 66490 }
14921
14922 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14923 692 {
14924 692 id=misc=clk;
14925 692 dir = clk & 3;
14926 692 clk=0;
14927 692 mainguy=count_enemy=false;
14928 692 dummy_bool[0]=false;
14929 692 item_set=0;
14930 692 bgsfx=-1;
14931 692 deadsfx = WAV_EDEAD;
14932
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14933 692 isCore = false;
14934
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14935 692 }
14936
14937 200202 bool esManhandla::animate(int32_t index)
14938 {
14939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14940
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14941 7008 return Dead(index);
14942
14943
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14944 {
14945 12404 removearmos(x,y,ffcactivated);
14946 12404 }
14947
14948
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14949 {
14950 27896 clk2=unsigned(zc_oldrand())%5+5;
14951 27896 clk3^=1;
14952 27896 }
14953
14954
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14955 {
14956 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14957 1491 sfx(wpnsfx(wpn),pan(int32_t(x)));
14958 1491 }
14959
14960 193194 return enemy::animate(index);
14961 200202 }
14962
14963 200186 void esManhandla::draw(BITMAP *dest)
14964 {
14965 200186 tile=o_tile;
14966 200186 int32_t fdiv = frate/4;
14967
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14968
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14969 200186 efrate:((clk>=(frate>>1))?1:0);
14970
14971
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14972 {
14973
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14974 {
14975 case up:
14976 39945 break;
14977
14978 case down:
14979 36845 tile+=4;
14980 36845 break;
14981
14982 case left:
14983 39966 tile+=8;
14984 39966 break;
14985
14986 case right:
14987 41960 tile+=12;
14988 41960 break;
14989 }
14990
14991 158716 tile+=f2;
14992 158716 }
14993 else
14994 {
14995
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
14996 {
14997 case down:
14998 8961 flip=2;
14999
15000 [[fallthrough]];
15001 case up:
15002 21355 tile=(clk3)?188:189;
15003 21355 break;
15004
15005 case right:
15006 12232 flip=1;
15007 [[fallthrough]];
15008
15009 case left:
15010 20115 tile=(clk3)?186:187;
15011 20115 break;
15012 }
15013 }
15014
15015 200186 enemy::draw(dest);
15016 200186 }
15017
15018 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
15019 168 {
15020
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
15021 {
15022
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 x = 120;
15023
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 y = 48;
15024 168 }
15025 else
15026 {
15027 if ( !(editorflags & ENEMY_FLAG6) )
15028 {
15029 x = X; y = Y;
15030 }
15031 else
15032 {
15033 x = X+8; y = Y;
15034 }
15035 }
15036 168 hzsz = 32; // can't be jumped.
15037 168 flameclk=0;
15038 168 misc=clk; // total head count
15039 168 clk3=clk; // live head count
15040 168 clk=0;
15041 168 clk2=60; // fire ball clock
15042 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
15043
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
15044 168 dir = down;
15045 168 hxofs=4;
15046 168 hit_width=8;
15047 // frate=17*4;
15048 168 fading=fade_blue_poof;
15049 //nets+5420;
15050
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
15051 {
15052 /*
15053 necktile=o_tile+8;
15054 if (dmisc3)
15055 {
15056 necktile+=8;
15057 }
15058 */
15059 133 necktile=o_tile+dmisc6;
15060 133 }
15061 else
15062 {
15063 35 necktile=s_tile;
15064 }
15065 168 }
15066
15067 155290 bool eGleeok::animate(int32_t index)
15068 {
15069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
15070
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
15071 2199 return Dead(index);
15072
15073
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
15074 {
15075 684 removearmos(x,y,ffcactivated);
15076 684 }
15077
15078 // Check if a head was killed somehow...
15079
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
15080 51372 clk3=guys.Count()-index-1;
15081
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
15082 87041 misc=guys.Count()-index-1;
15083
15084 //fix for the "kill all enemies" item
15085
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
15086 {
15087
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
15088 {
15089 // I haven't seen this fail, but it seems like it ought to be
15090 // possible, so I'm checking for it. - Saf
15091
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15092 break;
15093 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
15094 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
15095 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
15096 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
15097 12 }
15098
15099 6 clk3=0;
15100
15101
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
15102 {
15103
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15104 break;
15105 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15106 12 }
15107 6 }
15108
15109
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
15110 {
15111 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
15112 403171 head->dummy_int[1]=necktile;
15113 403171 head->parent_script_UID = this->script_UID;
15114
15115
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
15116 {
15117 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
15118 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
15119 320127 }
15120 else
15121 {
15122 83044 head->dummy_int[2]=necktile+1; //connected head tile
15123 83044 head->dummy_int[3]=necktile+2; //flying head tile
15124 }
15125
15126 403171 head->dmisc5=dmisc5; //neck segments
15127
15128 /*
15129 if (dmisc3)
15130 {
15131 head->dummy_bool[0]=true;
15132 }
15133 */
15134
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
15135 {
15136
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
15137 {
15138 1228 hp -= 1000 - head->hp;
15139 1228 hclk = 33;
15140
15141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
15142
15143 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
15144 1228 }
15145
15146 5655 head->hclk = 0;
15147 5655 }
15148
15149 // Must be set in case of naughty ZScripts
15150 403171 head->hp = 1000;
15151 403171 }
15152
15153
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
15154 {
15155 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
15156 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
15157 415 }
15158
15159
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
15160 {
15161
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
15162 {
15163 1287 int32_t i=zc_oldrand()%misc;
15164 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
15165 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
15166 1287 sfx(wpnsfx(wpn),pan(int32_t(x)));
15167 1287 clk2=0;
15168 1287 }
15169 95682 }
15170 else
15171 {
15172
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
15173 {
15174 557 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
15175 557 head->timer=zc_oldrand()%50+50;
15176 557 clk2=0;
15177 557 }
15178 }
15179
15180
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
15181 {
15182
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
15183 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15184
15185
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(index);
15186 127 }
15187
15188 153091 return enemy::animate(index);
15189 155290 }
15190
15191 1239 int32_t eGleeok::takehit(weapon*,weapon*)
15192 {
15193 1239 return 0;
15194 }
15195
15196 156918 void eGleeok::draw(BITMAP *dest)
15197 {
15198 156918 tile=o_tile;
15199
15200
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
15201 {
15202 2199 enemy::draw(dest);
15203 2199 return;
15204 }
15205
15206 154719 int32_t f=clk/17;
15207
15208
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
15209 {
15210 // body
15211 120524 xofs=-8;
15212 120524 yofs=32;
15213
15214
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
15215
15216 {
15217 case 0:
15218 9155 tile+=0;
15219 9155 break;
15220
15221 case 1:
15222 10095 tile+=2;
15223 10095 break;
15224
15225 case 2:
15226 8686 tile+=4;
15227 8686 break;
15228
15229 default:
15230 92588 tile+=6;
15231 92588 break;
15232 }
15233 120524 }
15234 else
15235 {
15236 // body
15237 34195 xofs=-8;
15238 34195 yofs=32;
15239
15240
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
15241 {
15242 case 0:
15243 2514 tile+=0;
15244 2514 break;
15245
15246 case 2:
15247 2459 tile+=4;
15248 2459 break;
15249
15250 default:
15251 29222 tile+=2;
15252 29222 break;
15253 }
15254 }
15255
15256 154719 enemy::drawblock(dest,15);
15257 156918 }
15258
15259 156918 void eGleeok::draw2(BITMAP *dest)
15260 {
15261 // the neck stub
15262 156918 tile=necktile;
15263 156918 xofs=0;
15264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15265
15266
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
15267 {
15268 122181 tile+=((clk&24)>>3);
15269 122181 }
15270
15271
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
15272 {
15273
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15274 737 sprite::drawcloaked(dest);
15275 else
15276 153982 sprite::draw(dest);
15277 154719 }
15278 156918 }
15279
15280
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
15281 533 {
15282
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
15283
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
15284 // dummy_bool[0]=false;
15285 533 timer=0;
15286 /* fixing */
15287 533 hp=1000;
15288
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
15289 533 item_set=0;
15290 //x=120; y=70;
15291
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
15292
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
15293 533 hxofs=4;
15294 533 hit_width=8;
15295
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15296 533 clk2=clk; // how int32_t to wait before moving first time
15297 533 clk=0;
15298 533 mainguy=count_enemy=false;
15299
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
15300 533 clk3=((dir&2)>>1)+2; // left or right
15301 533 dir&=1; // up or down
15302
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
15303 533 isCore = false;
15304
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
15305
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15306 {
15307 2132 nxoffset[i] = 0;
15308 2132 nyoffset[i] = 0;
15309
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15310
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15311 2132 }
15312
15313 533 necktile=0;
15314 //TODO compatibility? -DD
15315 /*
15316 for(int32_t i=0; i<4; i++)
15317 {
15318 nx[i]=124;
15319 ny[i]=i*6+48;
15320 }*/
15321 533 bgsfx=-1;
15322 //no need for deadsfx
15323 533 }
15324
15325 515535 bool esGleeok::animate(int32_t index)
15326 {
15327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15328 // don't call removearmos() - it's a segment.
15329
15330 515535 dmisc5=vbound(dmisc5,1,255);
15331
15332
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15333 {
15334 402762 x = (xoffset+parent->x);
15335 402762 y = (yoffset+parent->y);
15336
15337
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15338 {
15339 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15340 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15341 1611048 }
15342 402762 }
15343
15344 // set up the head tiles
15345 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15346 /*
15347 if (dummy_bool[0]) //if this is a flame gleeok
15348 {
15349 headtile+=180;
15350 }
15351 */
15352 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15353 515535 flyingheadtile=dummy_int[3];
15354
15355 // set up the neck tiles
15356 515535 necktile=dummy_int[1];
15357
15358
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15359 {
15360 402833 necktile+=((clk&24)>>3);
15361 402833 }
15362
15363 /*
15364 else
15365 {
15366 necktile=145;
15367 }
15368 */
15369 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15370
15371
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15372 {
15373 case 0: // live head
15374 // set up the attached head tiles
15375 402762 tile=headtile;
15376
15377
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15378 {
15379 319820 tile+=((clk&24)>>3);
15380 /*
15381 if (dummy_bool[0]) {
15382 tile+=1561;
15383 }
15384 */
15385 319820 }
15386
15387 /*
15388 else
15389 {
15390 tile=146;
15391 }
15392 */
15393
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15394 {
15395
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15396
15397
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15398
15399
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15400 {
15401 292 dir^=1;
15402 292 }
15403
15404 92832 zfix tempx = x;
15405 92832 zfix tempy = y;
15406
15407 92832 sprite::move(step);
15408 92832 xoffset += (x-tempx);
15409 92832 yoffset += (y-tempy);
15410
15411
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15412 {
15413 3863 clk3^=1;
15414 3863 clk2=-4;
15415 3863 }
15416 else
15417 {
15418
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15419 {
15420 978 clk3=right;
15421 978 }
15422
15423
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15424 {
15425 961 clk3=left;
15426 961 }
15427
15428
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15429 {
15430 3713 clk3^=1; // x jig
15431 3713 }
15432 else
15433 {
15434
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15435 {
15436 851 clk3^=1; // x switch back
15437 851 }
15438
15439 85256 clk2=-4;
15440 }
15441 }
15442
15443 92832 zc_swap(dir,clk3);
15444 92832 tempx = x;
15445 92832 tempy = y;
15446 92832 sprite::move(step);
15447 92832 xoffset += (x-tempx);
15448 92832 yoffset += (y-tempy);
15449 92832 zc_swap(dir,clk3);
15450
15451
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15452 {
15453 278496 nxoffset[i] = (zc_oldrand()%3);
15454 278496 nyoffset[i] = (zc_oldrand()%3);
15455 278496 }
15456 92832 }
15457
15458 402762 break;
15459
15460 case 1: // flying head
15461
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15462
15463 {
15464 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15465 105482 }
15466
15467 112071 break;
15468
15469 // the following are messages sent from the main guy...
15470 case -1: // got chopped off
15471 {
15472 300 misc=1;
15473 300 superman=1;
15474 300 hxofs=xofs=0;
15475 300 hit_width=16;
15476 300 cs=8;
15477 300 clk=-24;
15478 300 clk2=40;
15479 300 dir=(zc_oldrand()&7)+8;
15480 300 step=8.0/9.0;
15481 }
15482 300 break;
15483
15484 case -2: // the big guy is dead
15485 402 return true;
15486 }
15487
15488
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15489 {
15490
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15491 {
15492 4791 FireBreath(true);
15493 4791 }
15494
15495 40125 --timer;
15496 40125 }
15497
15498 515133 return enemy::animate(index);
15499 515535 }
15500
15501 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15502 {
15503
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15504 {
15505 int32_t wpnId = w->id;
15506
15507 if(dying)
15508 return 0;
15509
15510 switch(wpnId)
15511 {
15512 case wLitBomb:
15513 case wLitSBomb:
15514 case wBait:
15515 case wWhistle:
15516 case wFire:
15517 case wWind:
15518 case wSSparkle:
15519 case wFSparkle:
15520 case wPhantom:
15521 return 0;
15522
15523 case wHookshot:
15524 case wBrang:
15525 case wBeam:
15526 case wArrow:
15527 case wMagic:
15528 case wBomb:
15529 case wSBomb:
15530 sfx(WAV_CHINK,pan(int32_t(x)));
15531 break;
15532 default:
15533 break;
15534 }
15535
15536 return 1;
15537 }
15538 else
15539 {
15540 7080 int32_t ret = enemy::takehit(w,realweap);
15541
15542
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15543 5655 return 2; // force it to wait a frame before checking sword attacks again
15544
15545 1425 return ret;
15546 }
15547 7080 }
15548
15549 521456 void esGleeok::draw(BITMAP *dest)
15550 {
15551 521456 dmisc5=vbound(dmisc5,1,255);
15552
15553
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15554 {
15555 case 0: //neck
15556
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15557 {
15558
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15559 {
15560
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15561 {
15562
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15563 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
15564 else
15565 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
15566 978198 }
15567 else
15568 {
15569
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15570 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
15571 else
15572 249120 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
15573 }
15574 1227318 }
15575 409106 }
15576
15577 409106 break;
15578
15579 case 1: //flying head
15580 112350 tile=flyingheadtile;
15581
15582
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15583 {
15584 82692 tile+=((clk&24)>>3);
15585 82692 break;
15586 }
15587
15588 /*
15589 else
15590 {
15591 tile=(clk&1)?147:148;
15592 break;
15593 }
15594 */
15595 29658 }
15596 521456 }
15597
15598 521456 void esGleeok::draw2(BITMAP *dest)
15599 {
15600 521456 enemy::draw(dest);
15601 521456 }
15602
15603 190 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15604 190 {
15605
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ( !(editorflags & ENEMY_FLAG5) )
15606 {
15607
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 x = 128;
15608
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 y = 48;
15609 190 }
15610 else { x = X; y = Y; }
15611 190 adjusted=false;
15612
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 dir=(zc_oldrand()&7)+8;
15613 //step=0.25;
15614 190 flycnt=dmisc1;
15615 190 flycnt2=dmisc2;
15616 190 loopcnt=0;
15617 190 clk4 = 0;
15618 190 clk5 = 0;
15619 190 clk6 = 0;
15620 190 clk7 = 0;
15621
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc29 == 0)
15623 {
15624
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15625 {
15626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15627 105 else dmisc29 = (84 / 3);
15628 105 }
15629 else
15630 {
15631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc29 = (90 / 2);
15632 85 else dmisc29 = (84 / 2);
15633 }
15634 190 }
15635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc30 == 0)
15636 {
15637
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15638 {
15639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15640 105 else dmisc30 = (84 / 3)*0.5;
15641 105 }
15642 else
15643 {
15644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15645 85 else dmisc30 = (84 / 2)*0.5;
15646 }
15647 190 }
15648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc31 == 0)
15649 {
15650
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15651 {
15652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15653 105 else dmisc31 = (84 / 3)*2;
15654 105 }
15655 else
15656 {
15657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15658 85 else dmisc31 = (84 / 2)*0.5;
15659 }
15660 190 }
15661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if (dmisc32 == 0)
15662 {
15663
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 105 times.
190 if(!dmisc4)
15664 {
15665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15666 105 else dmisc32 = (84 / 3);
15667 105 }
15668 else
15669 {
15670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85 times.
85 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15671 85 else dmisc32 = (84 / 2)*0.25;
15672 }
15673 190 }
15674
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 init_size_flags();
15675 190 }
15676
15677 161885 bool ePatra::animate(int32_t index)
15678 {
15679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161885 times.
161885 if(switch_hooked) return enemy::animate(index);
15680
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 160441 times.
161885 if(dying)
15681 {
15682
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1444 times.
1516 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15683 {
15684 72 ((enemy*)guys.spr(i))->hp = -1000;
15685 72 }
15686
15687 1444 return Dead(index);
15688 }
15689
15690 160441 double basesize = 84;
15691
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc10) basesize = 90;
15692 160441 double halfsize = basesize / 2;
15693 160441 double quartersize = halfsize / 2;
15694 160441 double twothirdsize = (basesize / 3)*2;
15695 160441 double onethirdsize = (basesize / 3);
15696
15697
15698
2/2
✓ Branch 0 taken 123507 times.
✓ Branch 1 taken 36934 times.
160441 if(clk==0)
15699 {
15700 36934 removearmos(x,y,ffcactivated);
15701 36934 }
15702
15703
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160441 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
160441 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15704 {
15705
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
160441 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15706
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (loopcnt < 0) ++clk2;
15707
2/2
✓ Branch 0 taken 158644 times.
✓ Branch 1 taken 1797 times.
160441 if(++clk2>basesize)
15708 {
15709 1797 clk2=0;
15710
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1797 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1797 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15711 {
15712
2/2
✓ Branch 0 taken 932 times.
✓ Branch 1 taken 865 times.
1797 if(loopcnt > 0)
15713 932 --loopcnt;
15714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if (loopcnt == 0)
15715 {
15716
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 356 times.
865 if((misc%dmisc6)==0)
15717 {
15718
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 if (dmisc21 > 0) loopcnt=-dmisc21;
15719 356 else loopcnt=dmisc7;
15720 356 }
15721 865 }
15722 else if (loopcnt == -1) loopcnt=dmisc7;
15723 else ++loopcnt;
15724
15725
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1797 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15726 1797 }
15727 else
15728 {
15729 loopcnt = 0;
15730 misc = 1;
15731 }
15732 1797 }
15733 160441 }
15734
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk4 > 0) --clk4;
15735
15736
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 < 0)
15737 {
15738 if (dmisc5 == 1 || dmisc5 == 3)
15739 {
15740 if (get_qr(qr_NEWENEMYTILES))
15741 {
15742 if (clk7 <= 0 || clk6 != -16) ++clk6;
15743 if (clk6 == 0) o_tile=d->e_tile;
15744 else
15745 {
15746 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15747 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15748 }
15749 }
15750 else clk6 = 0;
15751 }
15752 }
15753
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk6;
15754
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk5 < 0) ++clk5;
15755
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 else if (dmisc19) ++clk5;
15756
15757
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160441 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160441 if (clk7 > 0 && clk6 >= -16) --clk7;
15758
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (clk6 > 0) clk7 = 0;
15759
15760
2/2
✓ Branch 0 taken 660384 times.
✓ Branch 1 taken 160441 times.
820825 for(int32_t i=index+1; i<index+flycnt+1; i++)
15761 {
15762 //outside ring
15763
2/2
✓ Branch 0 taken 659040 times.
✓ Branch 1 taken 1344 times.
660384 if(!adjusted)
15764 {
15765
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 192 times.
1344 if(get_qr(qr_NEWENEMYTILES))
15766 {
15767 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15768 1152 enemy *s = ((enemy*)guys.spr(i));
15769 1152 s->parent_script_UID = this->script_UID;
15770 1152 }
15771 else
15772 {
15773 192 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15774 192 enemy *s = ((enemy*)guys.spr(i));
15775 192 s->parent_script_UID = this->script_UID;
15776 }
15777
15778 1344 ((enemy*)guys.spr(i))->cs=dmisc9;
15779 1344 ((enemy*)guys.spr(i))->hp=dmisc3;
15780 1344 }
15781
15782
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 659620 times.
660384 if(((enemy*)guys.spr(i))->hp <= 0)
15783 {
15784
2/2
✓ Branch 0 taken 2889 times.
✓ Branch 1 taken 764 times.
3653 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15785 {
15786 2889 guys.swap(j,j+1);
15787 2889 }
15788
15789
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 670 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
764 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15790 764 }
15791 else
15792 {
15793 659620 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15794
1/2
✓ Branch 0 taken 659620 times.
✗ Branch 1 not taken.
659620 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15795
15796
2/2
✓ Branch 0 taken 212037 times.
✓ Branch 1 taken 447583 times.
659620 if(!dmisc4) //Big Ring
15797 {
15798 //maybe playing_field_offset here?
15799
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15800 {
15801
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15802
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15803 237330 }
15804 else
15805 {
15806 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15807 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15808 }
15809
15810 447583 temp_x=guys.spr(i)->x;
15811 447583 temp_y=guys.spr(i)->y;
15812 447583 }
15813 else //Oval
15814 {
15815 212037 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15816 212037 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15817
15818
2/2
✓ Branch 0 taken 121041 times.
✓ Branch 1 taken 90996 times.
212037 if(loopcnt>0)
15819 {
15820 121041 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15821
1/2
✓ Branch 0 taken 121041 times.
✗ Branch 1 not taken.
121041 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15822 121041 }
15823 else
15824 {
15825 90996 guys.spr(i)->x = circle_x;
15826 90996 guys.spr(i)->y = circle_y;
15827 }
15828
15829 212037 temp_x=circle_x;
15830 212037 temp_y=circle_y;
15831 }
15832
15833 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15834 659620 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15835
15836
4/4
✓ Branch 0 taken 124008 times.
✓ Branch 1 taken 535612 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83117 times.
659620 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15837 {
15838 83117 guys.spr(i)->dir=l_down;
15839 83117 }
15840
4/4
✓ Branch 0 taken 124459 times.
✓ Branch 1 taken 452044 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 83568 times.
576503 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15841 {
15842 83568 guys.spr(i)->dir=left;
15843 83568 }
15844
4/4
✓ Branch 0 taken 123345 times.
✓ Branch 1 taken 369590 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82454 times.
492935 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15845 {
15846 82454 guys.spr(i)->dir=l_up;
15847 82454 }
15848
4/4
✓ Branch 0 taken 123079 times.
✓ Branch 1 taken 287402 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 82188 times.
410481 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15849 {
15850 82188 guys.spr(i)->dir=up;
15851 82188 }
15852
4/4
✓ Branch 0 taken 122491 times.
✓ Branch 1 taken 205802 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81600 times.
328293 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15853 {
15854 81600 guys.spr(i)->dir=r_up;
15855 81600 }
15856
4/4
✓ Branch 0 taken 122884 times.
✓ Branch 1 taken 123809 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81993 times.
246693 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15857 {
15858 81993 guys.spr(i)->dir=right;
15859 81993 }
15860
4/4
✓ Branch 0 taken 122590 times.
✓ Branch 1 taken 42110 times.
✓ Branch 2 taken 40891 times.
✓ Branch 3 taken 81699 times.
164700 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15861 {
15862 81699 guys.spr(i)->dir=r_down;
15863 81699 }
15864 else
15865 {
15866 83001 guys.spr(i)->dir=down;
15867 }
15868
15869 659620 guys.spr(i)->x += x;
15870 659620 guys.spr(i)->y += y;
15871 }
15872 660384 }
15873
15874
7/22
✓ Branch 0 taken 106957 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106957 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
160441 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15875 {
15876 32331 int timeneeded = 48;
15877 32331 int patbreath = (zc_oldrand()%50+50);
15878
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15879
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15880 {
15881 timeneeded = 48 + patbreath;
15882 }
15883
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15884 {
15885 timeneeded = 48 + 96;
15886 }
15887
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15888
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15889
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15890 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15891 249 && (clk6 >= 0) //if not in the middle of firing...
15892 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15893
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15894 {
15895
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15896 {
15897 case patratSTREAM:
15898 {
15899 clk7 = 97;
15900 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15901 else clk6 = 0;
15902 break;
15903 }
15904 case patratBREATH:
15905 {
15906 clk7 = patbreath;
15907 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15908 else clk6 = 0;
15909 break;
15910 }
15911 default:
15912 {
15913
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15914 {
15915 clk6 = -48;
15916 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15917 }
15918 else
15919 {
15920 249 clk6 = 0;
15921
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15922 249 FirePatraWeapon();
15923 }
15924 249 break;
15925 }
15926 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15927 249 }
15928
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15929 {
15930 switch(dmisc28)
15931 {
15932 case patratSTREAM:
15933 {
15934 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15935 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15936 break;
15937 }
15938 case patratBREATH:
15939 {
15940 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15941 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15942 break;
15943 }
15944 default:
15945 {
15946 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15947 {
15948 FirePatraWeapon();
15949 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15950 }
15951 break;
15952 }
15953 }
15954 }
15955 32331 }
15956
15957 160441 int randattempts = 0;
15958 160441 int randeye = 0;
15959
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if (flycnt2 > 0)
15960 {
15961 46240 do
15962 {
15963
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15964 46240 randeye += (index + flycnt + 1);
15965 46240 ++randattempts;
15966
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15967 46240 }
15968 160441 bool dofire = false;
15969
1/2
✓ Branch 0 taken 160441 times.
✗ Branch 1 not taken.
160441 if (dmisc20)
15970 {
15971 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15972 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15973 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15974 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15975 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15976 {
15977 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15978 {
15979 if (clk5 >= dmisc19)
15980 {
15981 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15982 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
15983 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
15984 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
15985 || dmisc18 == -1)
15986 dofire = true;
15987 }
15988 }
15989 }
15990 }
15991
2/2
✓ Branch 0 taken 114201 times.
✓ Branch 1 taken 46240 times.
160441 if(flycnt2)
15992 {
15993
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
15994 {
15995
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
15996 {
15997 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
15998
15999
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
16000 {
16001
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16002 {
16003
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
16004 {
16005 // Center eye shoots projectiles; make room for its firing tiles
16006 case 1:
16007 case 3:
16008 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
16009 144 break;
16010
16011 // Center eyes does not shoot; use tiles two rows below for inner eyes.
16012 default:
16013 case 2:
16014 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
16015 168 break;
16016 }
16017 312 }
16018 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
16019 312 }
16020 else
16021 {
16022 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16023 }
16024
16025 312 ((enemy*)guys.spr(i))->cs=dmisc9;
16026
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
16027 312 }
16028
16029
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
16030 {
16031 263816 ((enemy*)guys.spr(i))->superman=true;
16032 263816 }
16033 else
16034 {
16035 70613 ((enemy*)guys.spr(i))->superman=false;
16036 }
16037
16038
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
16039 {
16040
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16041 {
16042 269 guys.swap(j,j+1);
16043 269 }
16044
16045
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
16046 145 }
16047 else
16048 {
16049 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16050
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
16051
16052
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
16053 {
16054
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
16055 {
16056
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16057
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16058 168378 }
16059 else
16060 {
16061 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16062 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16063 }
16064
16065 327025 temp_x=guys.spr(i)->x;
16066 327025 temp_y=guys.spr(i)->y;
16067 327025 }
16068 else
16069 {
16070 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16071 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16072
16073
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
16074 {
16075 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16076
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
16077 3965 }
16078 else
16079 {
16080 3294 guys.spr(i)->x = circle_x;
16081 3294 guys.spr(i)->y = circle_y;
16082 }
16083
16084 7259 temp_x=circle_x;
16085 7259 temp_y=circle_y;
16086 }
16087
16088 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16089 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16090
16091
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16092 {
16093 41746 guys.spr(i)->dir=l_down;
16094 41746 }
16095
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16096 {
16097 41734 guys.spr(i)->dir=left;
16098 41734 }
16099
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16100 {
16101 41742 guys.spr(i)->dir=l_up;
16102 41742 }
16103
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16104 {
16105 41758 guys.spr(i)->dir=up;
16106 41758 }
16107
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16108 {
16109 41830 guys.spr(i)->dir=r_up;
16110 41830 }
16111
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16112 {
16113 41824 guys.spr(i)->dir=right;
16114 41824 }
16115
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16116 {
16117 41852 guys.spr(i)->dir=r_down;
16118 41852 }
16119 else
16120 {
16121 41798 guys.spr(i)->dir=down;
16122 }
16123
16124 334284 guys.spr(i)->x += x;
16125 334284 guys.spr(i)->y = y-guys.spr(i)->y;
16126
16127
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
16128 {
16129 /*
16130 if(!(zc_oldrand()&127))
16131 {
16132 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
16133 sfx(wpnsfx(wpn),pan(int32_t(x)));
16134 }
16135 */
16136
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
16137 {
16138 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
16139 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16140 {
16141 if (dmisc5 == 3)
16142 {
16143 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16144 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
16145 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
16146 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16147 }
16148 else
16149 {
16150 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16151 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16152 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
16153 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16154 }
16155 }
16156 else
16157 {
16158 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16159 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
16160 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
16161 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16162 }
16163 }
16164
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
16165
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
16166
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
16167 {
16168
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
16169 {
16170 case 4: //Single one rapidfires
16171 {
16172 if (dofire && i == randeye)
16173 {
16174 ((esPatra*)guys.spr(i))->clk5 = -16;
16175 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
16176 ((esPatra*)guys.spr(i))->clk4 = 96;
16177 clk5 = -3;
16178 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16179 }
16180 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
16181 {
16182 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16183 sfx(wpnsfx(wpn),pan(int32_t(x)));
16184 }
16185 break;
16186 }
16187 case 3: //Ring
16188 {
16189 if (dofire)
16190 {
16191 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16192 {
16193 ((esPatra*)guys.spr(i))->clk5 = -48;
16194 clk5 = -48;
16195 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16196 }
16197 else
16198 {
16199 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16200 sfx(wpnsfx(wpn),pan(int32_t(x)));
16201 int32_t m=Ewpns.Count()-1;
16202 weapon *ew = (weapon*)(Ewpns.spr(m));
16203
16204 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16205 ((esPatra*)guys.spr(i))->clk5 = 0;
16206 clk5 = 0;
16207 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16208 }
16209 }
16210 if (((esPatra*)guys.spr(i))->clk5 == -16)
16211 {
16212 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16213 sfx(wpnsfx(wpn),pan(int32_t(x)));
16214 int32_t m=Ewpns.Count()-1;
16215 weapon *ew = (weapon*)(Ewpns.spr(m));
16216
16217 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16218 }
16219 break;
16220 }
16221 case 2: //one after another
16222 {
16223 if (dofire)
16224 {
16225 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
16226 clk5 = -48 - (12*flycnt2);
16227 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16228 }
16229 if (((esPatra*)guys.spr(i))->clk5 == -16)
16230 {
16231 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16232 sfx(wpnsfx(wpn),pan(int32_t(x)));
16233 }
16234 break;
16235 }
16236 case 1: //random one eye
16237 {
16238 if (dofire && i == randeye)
16239 {
16240 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16241 {
16242 ((esPatra*)guys.spr(i))->clk5 = -48;
16243 clk5 = -48;
16244 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16245 }
16246 else
16247 {
16248 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16250 ((esPatra*)guys.spr(i))->clk5 = 0;
16251 clk5 = 0;
16252 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16253 }
16254 }
16255 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16256 {
16257 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16258 sfx(wpnsfx(wpn),pan(int32_t(x)));
16259 }
16260 break;
16261 }
16262 default: //old behavior, all eyes can fire any time
16263 {
16264
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16265
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16266
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16267 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
16268 {
16269
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16270 {
16271 ((esPatra*)guys.spr(i))->clk5 = -48;
16272 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16273 }
16274 else
16275 {
16276 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16277 1155 sfx(wpnsfx(wpn),pan(int32_t(x)));
16278 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
16279
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16280 }
16281 1155 }
16282
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16283 {
16284 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16285 sfx(wpnsfx(wpn),pan(int32_t(x)));
16286 }
16287 145268 break;
16288 }
16289 }
16290 145268 }
16291 145268 }
16292
16293 }
16294 334429 }
16295 46240 }
16296
16297 160441 adjusted=true;
16298 160441 return enemy::animate(index);
16299 161885 }
16300
16301 249 void ePatra::FirePatraWeapon()
16302 { //.707
16303 249 int32_t xoff = 0;
16304 249 int32_t yoff = 0;
16305
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
16306 {
16307 xoff += (hit_width/2)-8;
16308 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
16309 }
16310
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
16311 {
16312 yoff += (hit_height/2)-8;
16313 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
16314 }
16315 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16316
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16317 {
16318 case patrat8SHOT: //Fire Wizzrobe
16319 case patrat4SHOTDIAG:
16320 case patrat4SHOTRAND:
16321 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16322 {
16323 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16324 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16325 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16326 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16327
16328 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16329 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16331 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16332
16333 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16334 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16335 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16336 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16337
16338 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16339 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16340 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16341 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16342
16343 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16344 }
16345
16346 [[fallthrough]];
16347 case patrat4SHOTCARD: //Stalfos 3
16348 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16349 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16350 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16351 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16352 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16353 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16354 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16356 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16357 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16358 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16359 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16360 break;
16361
16362 default:
16363 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16364
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16365 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16366
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16367
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16368 {
16369 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16370 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16371 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16372 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16373 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16374 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16375 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16376 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16377 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16378 {
16379 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16380 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16381 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16382 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16383 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16384 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16385 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16386 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16387 }
16388 }
16389 249 break;
16390
16391 }
16392 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16393 //+0.46364761
16394 //11.80
16395 249 }
16396
16397 324242 void ePatra::draw(BITMAP *dest)
16398 {
16399 324242 tile=o_tile;
16400 324242 update_enemy_frame();
16401 324242 enemy::draw(dest);
16402 324242 }
16403
16404 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16405 {
16406 int32_t ret = enemy::defend(wpnId, power, edef);
16407
16408 if(ret < 0 && (flycnt||flycnt2))
16409 return 0;
16410
16411 return ret;
16412 }
16413
16414 1733 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16415 {
16416 1733 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16417
16418
6/6
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 834 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 332 times.
1733 if(ret < 0 && (flycnt||flycnt2))
16419 1281 return 0;
16420
16421 452 return ret;
16422 1733 }
16423
16424 190 void ePatra::init_size_flags() {
16425 190 SIZEflags = d->SIZEflags;
16426
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16427
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16428 // al_trace("Enemy txsz:%i\n", txsz);
16429
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
190 if (((SIZEflags & guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16430
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16431
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16432
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hit_width = 32;
16433
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16434
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (((SIZEflags & guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16436
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) hxofs = -8;
16437
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16438 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & guyflagOVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16440
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 else if (dmisc10 == 1) xofs = -8;
16441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if ((SIZEflags & guyflagOVERRIDE_DRAW_Y_OFFSET) != 0)
16442 {
16443 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16444 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16445 }
16446
1/4
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16447
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if (editorflags & ENEMY_FLAG8) misc = 1;
16448
16449
1/2
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
190 if ((SIZEflags & guyflagOVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16450
16451 190 }
16452
16453 3312 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16454 1656 {
16455 //cs=8;
16456 1656 item_set=0;
16457 1656 misc=clk;
16458 1656 clk4 = 0;
16459 1656 clk5 = 0;
16460 1656 clk = -((misc*21)>>1)-1;
16461
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16462 1656 hit_width=12;
16463 1656 hit_height=12;
16464 1656 hxofs=2;
16465 1656 hyofs=2;
16466 1656 extend = 0;
16467 1656 txsz = 1;
16468 1656 tysz = 1;
16469 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16470 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16471 int32_t prntSIZEflags = prntenemy->SIZEflags;
16472 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16473 // al_trace("Enemy txsz:%i\n", txsz);
16474 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16475 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16476 else
16477 hxsz=12;
16478 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16479 else
16480 hysz=12;
16481 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16482 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16483 else
16484 hxofs=2;
16485 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16486 else hyofs=2;
16487 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16488 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16489 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16490 {
16491 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16492 }
16493
16494 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16495 */
16496 1656 mainguy=count_enemy=false;
16497 1656 bgsfx=-1;
16498 //o_tile=0;
16499
2/4
✓ Branch 0 taken 1656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1656 times.
✗ Branch 3 not taken.
1656 flags &= (~guy_never_return);
16500 1656 deadsfx = WAV_EDEAD;
16501 1656 hitsfx = WAV_EHIT;
16502 1656 isCore = false;
16503 1656 }
16504
16505 1010584 bool esPatra::animate(int32_t index)
16506 {
16507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1010584 times.
1010584 if(switch_hooked) return enemy::animate(index);
16508
2/2
✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 995424 times.
1010584 if(dying)
16509 15160 return Dead(index);
16510
16511 995424 return enemy::animate(index);
16512 1010584 }
16513
16514 2028196 void esPatra::draw(BITMAP *dest)
16515 {
16516
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 306902 times.
2028196 if(get_qr(qr_NEWENEMYTILES))
16517 {
16518 1721294 tile = o_tile+(clk&3);
16519
16520
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16521 {
16522 case up: //u
16523 214278 flip=0;
16524 214278 break;
16525
16526 case down: //d
16527 217924 flip=0;
16528 217924 tile+=4;
16529 217924 break;
16530
16531 case left: //l
16532 215346 flip=0;
16533 215346 tile+=8;
16534 215346 break;
16535
16536 case right: //r
16537 215726 flip=0;
16538 215726 tile+=12;
16539 215726 break;
16540
16541 case l_up: //ul
16542 213062 flip=0;
16543 213062 tile+=20;
16544 213062 break;
16545
16546 case r_up: //ur
16547 214350 flip=0;
16548 214350 tile+=24;
16549 214350 break;
16550
16551 case l_down: //dl
16552 215734 flip=0;
16553 215734 tile+=28;
16554 215734 break;
16555
16556 case r_down: //dr
16557 214874 flip=0;
16558 214874 tile+=32;
16559 214874 break;
16560 }
16561 1721294 }
16562 else
16563 {
16564 306902 tile = o_tile+((clk&2)>>1);
16565 }
16566
16567
2/2
✓ Branch 0 taken 114856 times.
✓ Branch 1 taken 1913340 times.
2028196 if(clk>=0)
16568 1913340 enemy::draw(dest);
16569 2028196 }
16570
16571
16572 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16573 102 {
16574 102 adjusted=false;
16575
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16576
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16577 102 clk4 = 0;
16578 102 clk5 = 0;
16579 //flycnt=6; flycnt2=0;
16580 102 flycnt=dmisc1;
16581 102 flycnt2=0; // PatraBS doesn't have inner rings!
16582 102 loopcnt=0;
16583
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16585
16586 //nets+4480;
16587 102 }
16588
16589 35963 bool ePatraBS::animate(int32_t index)
16590 {
16591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16592
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16593 240 return Dead(index);
16594
16595
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16596 {
16597 4018 removearmos(x,y,ffcactivated);
16598 4018 }
16599
16600 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16601
16602
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16603 {
16604 336 clk2=0;
16605
16606
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16607 177 --loopcnt;
16608 else
16609 {
16610
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if((misc%dmisc6)==0)
16611 84 loopcnt=dmisc7;
16612 }
16613
16614 336 ++misc;
16615 336 }
16616
16617 // double size=1;;
16618
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16619 {
16620
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16621 {
16622 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16623
16624
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16625 {
16626 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16627 612 }
16628 else
16629 {
16630 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16631 }
16632
16633 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16634 612 }
16635
16636
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16637 {
16638
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16639 {
16640 131 guys.swap(j,j+1);
16641 131 }
16642
16643 104 --flycnt;
16644 104 }
16645 else
16646 {
16647 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16648
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16649 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16650 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16651
16652
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16653 {
16654 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16655
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16656 77643 }
16657 else
16658 {
16659 75725 guys.spr(i)->x = temp_x;
16660 75725 guys.spr(i)->y = temp_y;
16661 }
16662
16663 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16664 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16665
16666
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16667 {
16668 18812 guys.spr(i)->dir=l_down;
16669 18812 }
16670
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16671 {
16672 18839 guys.spr(i)->dir=left;
16673 18839 }
16674
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16675 {
16676 18802 guys.spr(i)->dir=l_up;
16677 18802 }
16678
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16679 {
16680 20143 guys.spr(i)->dir=up;
16681 20143 }
16682
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16683 {
16684 18517 guys.spr(i)->dir=r_up;
16685 18517 }
16686
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16687 {
16688 18779 guys.spr(i)->dir=right;
16689 18779 }
16690
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16691 {
16692 18992 guys.spr(i)->dir=r_down;
16693 18992 }
16694 else
16695 {
16696 20484 guys.spr(i)->dir=down;
16697 }
16698
16699 153368 guys.spr(i)->x += x;
16700 153368 guys.spr(i)->y += y;
16701 }
16702 153472 }
16703
16704 35723 adjusted=true;
16705 35723 return enemy::animate(index);
16706 35963 }
16707
16708 72874 void ePatraBS::draw(BITMAP *dest)
16709 {
16710 72874 tile=o_tile;
16711
16712
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16713 {
16714 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16715 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16716
16717
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16718 {
16719 19146 lookat=l_down;
16720 19146 }
16721
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16722 {
16723 18298 lookat=down;
16724 18298 }
16725
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16726 {
16727 13624 lookat=r_down;
16728 13624 }
16729
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16730 {
16731 7492 lookat=right;
16732 7492 }
16733
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16734 {
16735 1170 lookat=r_up;
16736 1170 }
16737
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16738 {
16739 964 lookat=up;
16740 964 }
16741
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16742 {
16743 1700 lookat=l_up;
16744 1700 }
16745 else
16746 {
16747 10480 lookat=left;
16748 }
16749
16750
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16751 {
16752 case up: //u
16753 964 flip=0;
16754 964 break;
16755
16756 case down: //d
16757 18298 flip=0;
16758 18298 tile+=8;
16759 18298 break;
16760
16761 case left: //l
16762 10480 flip=0;
16763 10480 tile+=40;
16764 10480 break;
16765
16766 case right: //r
16767 7492 flip=0;
16768 7492 tile+=48;
16769 7492 break;
16770
16771 case l_up: //ul
16772 1700 flip=0;
16773 1700 tile+=80;
16774 1700 break;
16775
16776 case r_up: //ur
16777 1170 flip=0;
16778 1170 tile+=88;
16779 1170 break;
16780
16781 case l_down: //dl
16782 19146 flip=0;
16783 19146 tile+=120;
16784 19146 break;
16785
16786 case r_down: //dr
16787 13624 flip=0;
16788 13624 tile+=128;
16789 13624 break;
16790 }
16791
16792 72874 tile+=(2*(clk&3));
16793 72874 xofs-=8;
16794 72874 yofs-=8;
16795 72874 drawblock(dest,15);
16796 72874 xofs+=8;
16797 72874 yofs+=8;
16798 72874 }
16799 else
16800 {
16801 flip=(clk&1);
16802 xofs-=8;
16803 yofs-=8;
16804 enemy::draw(dest);
16805 xofs+=16;
16806 enemy::draw(dest);
16807 yofs+=16;
16808 enemy::draw(dest);
16809 xofs-=16;
16810 enemy::draw(dest);
16811 xofs+=8;
16812 yofs-=8;
16813 }
16814 72874 }
16815
16816 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16817 {
16818 int32_t ret = enemy::defend(wpnId, power, edef);
16819
16820 if(ret < 0 && (flycnt||flycnt2))
16821 return 0;
16822
16823 return ret;
16824 }
16825
16826 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16827 {
16828 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16829
16830
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16831 81 return 0;
16832
16833 61 return ret;
16834 142 }
16835
16836 102 void ePatraBS::init_size_flags()
16837 {
16838 102 SIZEflags = d->SIZEflags;
16839
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16840 // al_trace("Enemy txsz:%i\n", txsz);
16841
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16842
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16843 102 else hit_width = 32;
16844
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16845
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & guyflagOVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16847 102 else hxofs = -8;
16848
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & guyflagOVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16849 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16850
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & guyflagOVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16851
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & guyflagOVERRIDE_DRAW_Y_OFFSET) != 0)
16852 {
16853 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16854 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16855 }
16856
16857
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & guyflagOVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16858 102 }
16859
16860 1224 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16861 612 {
16862 //cs=csBOSS;
16863 612 item_set=0;
16864 612 misc=clk;
16865 612 clk = -((misc*21)>>1)-1;
16866 612 clk4 = 0;
16867 612 clk5 = 0;
16868
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16869 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16870
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16871 // al_trace("Enemy txsz:%i\n", txsz);
16872
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16874 612 else hit_width=16;
16875
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16876 612 else hit_height=16;
16877
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16878
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16880 612 else hyofs=2;
16881 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16882
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16884 {
16885 yofs = (int32_t)prntenemy->yofs;
16886 }
16887
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16888
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16889
16890 612 bgsfx=-1;
16891 612 mainguy=count_enemy=false;
16892 612 deadsfx = WAV_EDEAD;
16893 612 hitsfx = WAV_EHIT;
16894
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16895 612 isCore = false;
16896 612 }
16897
16898 155090 bool esPatraBS::animate(int32_t index)
16899 {
16900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16901
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16902 1552 return Dead(index);
16903
16904 153538 return enemy::animate(index);
16905 155090 }
16906
16907 315868 void esPatraBS::draw(BITMAP *dest)
16908 {
16909 315868 tile=o_tile;
16910
16911
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16912 {
16913
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16914 {
16915 case up: //u
16916 41612 flip=0;
16917 41612 break;
16918
16919 case down: //d
16920 42622 flip=0;
16921 42622 tile+=4;
16922 42622 break;
16923
16924 case left: //l
16925 37916 flip=0;
16926 37916 tile+=8;
16927 37916 break;
16928
16929 case right: //r
16930 38458 flip=0;
16931 38458 tile+=12;
16932 38458 break;
16933
16934 case l_up: //ul
16935 38564 flip=0;
16936 38564 tile+=20;
16937 38564 break;
16938
16939 case r_up: //ur
16940 38568 flip=0;
16941 38568 tile+=24;
16942 38568 break;
16943
16944 case l_down: //dl
16945 38662 flip=0;
16946 38662 tile+=28;
16947 38662 break;
16948
16949 case r_down: //dr
16950 39466 flip=0;
16951 39466 tile+=32;
16952 39466 break;
16953 }
16954
16955 315868 tile += ((clk&6)>>1);
16956 315868 }
16957 else
16958 {
16959 tile += (clk&4)?1:0;
16960 }
16961
16962
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16963 283752 enemy::draw(dest);
16964 315868 }
16965
16966 241822 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16967 {
16968
4/6
✓ Branch 0 taken 135636 times.
✓ Branch 1 taken 106186 times.
✓ Branch 2 taken 135636 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135636 times.
✗ Branch 5 not taken.
241822 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16969
4/8
✓ Branch 0 taken 241822 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 241822 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 241822 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 241822 times.
✗ Branch 7 not taken.
241822 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16970
1/2
✓ Branch 0 taken 241822 times.
✗ Branch 1 not taken.
241822 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16971 241822 }
16972
16973 74325 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16974 {
16975 // Kludge
16976
4/8
✓ Branch 0 taken 74325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74325 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74325 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74325 times.
✗ Branch 7 not taken.
74325 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16977 74325 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74325 times.
74325 delete w;
16979 74325 return ret;
16980 }
16981
16982 9138 void enemy_scored(int32_t index)
16983 {
16984 9138 ((enemy*)guys.spr(index))->scored=true;
16985 9138 }
16986
16987 2179 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
16988 {
16989
6/10
✓ Branch 0 taken 2179 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2179 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2179 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 272 times.
✓ Branch 7 taken 1907 times.
✓ Branch 8 taken 2179 times.
✗ Branch 9 not taken.
2179 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
16990
5/6
✓ Branch 0 taken 1269 times.
✓ Branch 1 taken 910 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1265 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2179 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
16991 {
16992 4 g->o_tile = parentscr->guytile;
16993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
16994 4 g->flags &= ~guy_invisible;
16995 4 g->cs = parentscr->guycs;
16996 4 }
16997 2179 guys.add(g);
16998 2179 }
16999
17000 23564 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17001 {
17002
4/8
✓ Branch 0 taken 23564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23564 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23564 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23564 times.
✗ Branch 7 not taken.
23564 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
17003 23564 items.add(i);
17004 23564 }
17005
17006 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
17007 {
17008
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
17009 150 items.add(i);
17010 150 }
17011
17012 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17013 {
17014
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
17015 3 items.add(i);
17016 3 }
17017
17018 96 void kill_em_all()
17019 {
17020
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
17021 {
17022 353 enemy *e = ((enemy*)guys.spr(i));
17023
17024
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17025
17026 323 e->kickbucket();
17027 323 }
17028 96 }
17029
17030 bool can_kill_em_all()
17031 {
17032 for(int32_t i=0; i<guys.Count(); i++)
17033 {
17034 enemy *e = ((enemy*)guys.spr(i));
17035
17036 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17037 if(e->superman) continue;
17038 return true;
17039 }
17040 return false;
17041 }
17042
17043 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
17044 // For Hero's hit detection. Don't count them if they are stunned or are guys.
17045 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17046 {
17047 for(int32_t i=0; i<guys.Count(); i++)
17048 {
17049 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17050 {
17051 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
17052 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
17053 {
17054 return i;
17055 }
17056 }
17057 }
17058
17059 return -1;
17060 }
17061
17062 13025621 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17063 {
17064
4/4
✓ Branch 0 taken 16489 times.
✓ Branch 1 taken 13009132 times.
✓ Branch 2 taken 33610047 times.
✓ Branch 3 taken 12994957 times.
46605004 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
17065 {
17066
2/2
✓ Branch 0 taken 30664 times.
✓ Branch 1 taken 33579383 times.
33610047 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17067 {
17068 30664 return i;
17069 }
17070 33579383 }
17071
17072 12994957 return -1;
17073 13025621 }
17074
17075 // For Hero's hit detection. Count them if they are dying.
17076 52195 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17077 {
17078 52195 enemy *e = (enemy*)guys.spr(index);
17079
3/4
✓ Branch 0 taken 52195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27823 times.
✓ Branch 3 taken 24372 times.
52195 if(!e || e->hp > 0)
17080 27823 return -1;
17081
17082 24372 bool d = e->dying;
17083 24372 int32_t hc = e->hclk;
17084 24372 e->dying = false;
17085 24372 e->hclk = 0;
17086 24372 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
17087 24372 e->dying = d;
17088 24372 e->hclk = hc;
17089
17090
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24215 times.
24372 return hit ? index : -1;
17091 52195 }
17092
17093 14185839 bool hasMainGuy()
17094 {
17095
2/2
✓ Branch 0 taken 15396025 times.
✓ Branch 1 taken 5544618 times.
20940643 for(int32_t i=0; i<guys.Count(); i++)
17096 {
17097
2/2
✓ Branch 0 taken 8641221 times.
✓ Branch 1 taken 6754804 times.
15396025 if(((enemy*)guys.spr(i))->mainguy)
17098 {
17099 8641221 return true;
17100 }
17101 6754804 }
17102
17103 5544618 return false;
17104 14185839 }
17105
17106 138 void EatHero(int32_t index)
17107 {
17108 138 ((eStalfos*)guys.spr(index))->eathero();
17109 138 }
17110
17111 9 void GrabHero(int32_t index)
17112 {
17113 9 ((eWallM*)guys.spr(index))->grabhero();
17114 9 }
17115
17116 1338 bool CarryHero()
17117 {
17118
1/2
✓ Branch 0 taken 3933 times.
✗ Branch 1 not taken.
3933 for(int32_t i=0; i<guys.Count(); i++)
17119 {
17120
2/2
✓ Branch 0 taken 2090 times.
✓ Branch 1 taken 1843 times.
3933 if(((guy*)(guys.spr(i)))->family==eeWALLM)
17121 {
17122
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 505 times.
1843 if(((eWallM*)guys.spr(i))->hashero)
17123 {
17124 1338 Hero.x=guys.spr(i)->x;
17125 1338 Hero.y=guys.spr(i)->y;
17126 1338 return ((eWallM*)guys.spr(i))->misc > 0;
17127 }
17128 505 }
17129
17130 // Like Likes currently can't carry Hero.
17131 /*
17132 if(((guy*)(guys.spr(i)))->family==eeLIKE)
17133 {
17134 if(((eLikeLike*)guys.spr(i))->hashero)
17135 {
17136 Hero.x=guys.spr(i)->x;
17137 Hero.y=guys.spr(i)->y;
17138 return (true);
17139 }
17140 }*/
17141 2595 }
17142
17143 return false;
17144 1338 }
17145
17146 // Move item with guy
17147 void movefairy(zfix &x,zfix &y,int32_t misc)
17148 {
17149 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17150
17151 if(i!=-1)
17152 {
17153 x = guys.spr(i)->x;
17154 y = guys.spr(i)->y;
17155 }
17156 }
17157
17158 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17159 void movefairy2(zfix x,zfix y,int32_t misc)
17160 {
17161 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17162
17163 if(i!=-1)
17164 {
17165 guys.spr(i)->x = x;
17166 guys.spr(i)->y = y;
17167 }
17168 }// Move item with guy
17169
17170 60438 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
17171 {
17172 60438 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17173
17174
1/2
✓ Branch 0 taken 60438 times.
✗ Branch 1 not taken.
60438 if(fairy)
17175 {
17176 60438 x = fairy->x;
17177 60438 y = fairy->y;
17178 60438 }
17179 60438 }
17180
17181 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17182 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
17183 {
17184 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17185
17186
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
17187 {
17188 404 fairy->x = x;
17189 404 fairy->y = y;
17190 404 }
17191 404 }
17192
17193 void killfairy(int32_t misc)
17194 {
17195 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17196 guys.del(i);
17197 }
17198
17199 217 int32_t getGuyIndex(const int32_t eid)
17200 {
17201
1/2
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
826 for(word i = 0; i < guys.Count(); i++)
17202 {
17203
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 609 times.
826 if(guys.spr(i)->getUID() == eid)
17204 217 return i;
17205 609 }
17206
17207 return -1;
17208 217 }
17209
17210 217 void killfairynew(item const &itemfairy)
17211 {
17212 217 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17213
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
17214 217 }
17215
17216 //Should probably change this to return an 'enemy*', null on failure -Em
17217 21705 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
17218 {
17219 21705 return addenemy(x,y,0,id,clk);
17220 }
17221
17222 1965 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
17223 {
17224 1965 return addchild(x,y,0,id,clk, parent_scriptUID);
17225 }
17226
17227 1997 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
17228 {
17229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
17230
17231 1997 int32_t ret = 0;
17232 1997 sprite *e=NULL;
17233 1997 al_trace("Adding child\n");
17234
17235
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17236 {
17237 //Fixme: possible enemy memory leak. (minor)
17238 case eeWALK:
17239
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17240 110 break;
17241
17242 case eeLEV:
17243 e = new eLeever((zfix)x,(zfix)y,id,clk);
17244 break;
17245
17246 case eeTEK:
17247 e = new eTektite((zfix)x,(zfix)y,id,clk);
17248 break;
17249
17250 case eePEAHAT:
17251 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17252 break;
17253
17254 case eeZORA:
17255 e = new eZora((zfix)x,(zfix)y,id,clk);
17256 break;
17257
17258 case eeGHINI:
17259 e = new eGhini((zfix)x,(zfix)y,id,clk);
17260 break;
17261
17262 case eeKEESE:
17263
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
17264 1865 break;
17265
17266 case eeWIZZ:
17267
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17268 15 break;
17269
17270 case eePROJECTILE:
17271 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17272 break;
17273
17274 case eeWALLM:
17275 e = new eWallM((zfix)x,(zfix)y,id,clk);
17276 break;
17277
17278 case eeAQUA:
17279 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17280 break;
17281
17282 case eeMOLD:
17283 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17284 break;
17285
17286 case eeMANHAN:
17287
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17288 1 break;
17289
17290 case eeGLEEOK:
17291 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17292 break;
17293
17294 case eeGHOMA:
17295 e = new eGohma((zfix)x,(zfix)y,id,clk);
17296 break;
17297
17298 case eeLANM:
17299 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17300 break;
17301
17302 case eeGANON:
17303 e = new eGanon((zfix)x,(zfix)y,id,clk);
17304 break;
17305
17306 case eeFAIRY:
17307 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17308 break;
17309
17310 case eeFIRE:
17311
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17312 2 break;
17313
17314 case eeOTHER:
17315 e = new eOther((zfix)x,(zfix)y,id,clk);
17316 break;
17317
17318
17319 case eeSCRIPT01:
17320 case eeSCRIPT02:
17321 case eeSCRIPT03:
17322 case eeSCRIPT04:
17323 case eeSCRIPT05:
17324 case eeSCRIPT06:
17325 case eeSCRIPT07:
17326 case eeSCRIPT08:
17327 case eeSCRIPT09:
17328 case eeSCRIPT10:
17329 case eeSCRIPT11:
17330 case eeSCRIPT12:
17331 case eeSCRIPT13:
17332 case eeSCRIPT14:
17333 case eeSCRIPT15:
17334 case eeSCRIPT16:
17335 case eeSCRIPT17:
17336 case eeSCRIPT18:
17337 case eeSCRIPT19:
17338 case eeSCRIPT20:
17339 {
17340 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17341 {
17342 e = new eScript((zfix)x,(zfix)y,id,clk);
17343 break;
17344 }
17345 else return 0;
17346 }
17347
17348 case eeFFRIENDLY01:
17349 case eeFFRIENDLY02:
17350 case eeFFRIENDLY03:
17351 case eeFFRIENDLY04:
17352 case eeFFRIENDLY05:
17353 case eeFFRIENDLY06:
17354 case eeFFRIENDLY07:
17355 case eeFFRIENDLY08:
17356 case eeFFRIENDLY09:
17357 case eeFFRIENDLY10:
17358 {
17359 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17360 {
17361 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17362 }
17363 else return 0;
17364
17365 }
17366
17367 case eeSPINTILE:
17368 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17369 break;
17370
17371 // and these enemies use the misc10/misc2 value
17372 case eeROCK:
17373 {
17374 switch(guysbuf[id&0xFFF].attributes[9])
17375 {
17376 case 1:
17377 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17378 break;
17379
17380 case 0:
17381 default:
17382 e = new eRock((zfix)x,(zfix)y,id,clk);
17383 break;
17384 }
17385
17386 break;
17387 }
17388
17389 case eeTRAP:
17390 {
17391 switch(guysbuf[id&0xFFF].attributes[1])
17392 {
17393 case 1:
17394 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17395 break;
17396
17397 case 0:
17398 default:
17399 e = new eTrap((zfix)x,(zfix)y,id,clk);
17400 break;
17401 }
17402
17403 break;
17404 }
17405
17406 case eeDONGO:
17407 {
17408 switch(guysbuf[id&0xFFF].attributes[9])
17409 {
17410 case 1:
17411 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17412 break;
17413
17414 case 0:
17415 default:
17416 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17417 break;
17418 }
17419
17420 break;
17421 }
17422
17423 case eeDIG:
17424 {
17425
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17426 {
17427 case 1:
17428 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17429 break;
17430
17431 4 case 0:
17432 default:
17433
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17434 4 break;
17435 }
17436
17437 4 break;
17438 }
17439
17440 case eePATRA:
17441 {
17442 switch(guysbuf[id&0xFFF].attributes[9])
17443 {
17444 case 1:
17445 if (get_qr(qr_HARDCODED_BS_PATRA))
17446 {
17447 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17448 break;
17449 }
17450 [[fallthrough]];
17451 case 0:
17452 default:
17453 e = new ePatra((zfix)x,(zfix)y,id,clk);
17454 break;
17455 }
17456
17457 break;
17458 }
17459
17460 case eeGUY:
17461 {
17462 switch(guysbuf[id&0xFFF].attributes[9])
17463 {
17464 case 1:
17465 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17466 break;
17467
17468 case 0:
17469 default:
17470 e = new eNPC((zfix)x,(zfix)y,id,clk);
17471 break;
17472 }
17473
17474 break;
17475 }
17476
17477 case eeNONE:
17478 if(guysbuf[id&0xFFF].attributes[9] ==1)
17479 {
17480 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17481 break;
17482 break;
17483 }
17484 [[fallthrough]];
17485 default:
17486
17487 return 0;
17488 }
17489
17490 1997 ret++; // Made one enemy.
17491
17492
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17493 {
17494 7 e->z = (zfix)z;
17495 7 }
17496
17497
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17498 1997 ((enemy*)e)->parent_script_UID = parent_scriptUID;
17499
17500
17501
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17502 {
17503 return 0;
17504 }
17505
17506 // add segments of segmented enemies
17507 1997 int32_t c=0;
17508
17509
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17510 {
17511 case eeMOLD:
17512 {
17513 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17514 id &= 0xFFF;
17515
17516 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17517 {
17518 //christ this is messy -DD
17519 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17520
17521 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17522 {
17523 al_trace("Moldorm segment %d could not be created!\n",i+1);
17524
17525 for(int32_t j=0; j<i+1; j++)
17526 guys.del(guys.Count()-1);
17527
17528 return 0;
17529 }
17530
17531 if(i>0)
17532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17533
17534 ret++;
17535 }
17536
17537 break;
17538 }
17539
17540 case eeLANM:
17541 {
17542 id &= 0xFFF;
17543 int32_t shft = guysbuf[id].attributes[1];
17544 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17545
17546 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17547 {
17548 al_trace("Lanmola segment 1 could not be created!\n");
17549 guys.del(guys.Count()-1);
17550 return 0;
17551 }
17552
17553 ret++;
17554
17555 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17556 {
17557 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17558 {
17559 al_trace("Lanmola segment %d could not be created!\n",i+1);
17560
17561 for(int32_t j=0; j<i+1; j++)
17562 guys.del(guys.Count()-1);
17563
17564 return 0;
17565 }
17566
17567 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17568 ret++;
17569 }
17570 }
17571 break;
17572
17573 case eeMANHAN:
17574 1 id &= 0xFFF;
17575
17576
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17577 {
17578
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17579 {
17580 al_trace("Manhandla head %d could not be created!\n",i+1);
17581
17582 for(int32_t j=0; j<i+1; j++)
17583 {
17584 guys.del(guys.Count()-1);
17585 }
17586
17587 return 0;
17588 }
17589
17590 4 ret++;
17591 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17592 4 }
17593
17594 1 break;
17595
17596 case eeGLEEOK:
17597 {
17598 id &= 0xFFF;
17599
17600 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17601 {
17602 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17603 {
17604 al_trace("Gleeok head %d could not be created!\n",i+1);
17605
17606 for(int32_t j=0; j<i+1; j++)
17607 {
17608 guys.del(guys.Count()-1);
17609 }
17610
17611 return false;
17612 }
17613
17614 c-=guysbuf[id].attributes[3];
17615 ret++;
17616 }
17617 }
17618 break;
17619
17620
17621 case eePATRA:
17622 {
17623 id &= 0xFFF;
17624 int32_t outeyes = 0;
17625
17626 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17627 {
17628 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17629 {
17630 al_trace("Patra outer eye %d could not be created!\n",i+1);
17631
17632 for(int32_t j=0; j<i+1; j++)
17633 guys.del(guys.Count()-1);
17634
17635 return 0;
17636 }
17637 else
17638 outeyes++;
17639
17640 ret++;
17641 }
17642
17643 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17644 {
17645 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17646 {
17647 al_trace("Patra inner eye %d could not be created!\n",i+1);
17648
17649 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17650 guys.del(guys.Count()-1);
17651
17652 return 0;
17653 }
17654
17655 ret++;
17656 }
17657
17658 break;
17659 }
17660 }
17661
17662 1997 return ret;
17663 1997 }
17664
17665 // Returns number of enemies/segments created
17666 101436 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17667 {
17668 101436 int32_t realid = id&0xFFF;
17669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101436 times.
101436 if( realid > MAXGUYS )
17670 {
17671 return 0;
17672 }
17673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101436 times.
101436 if(id <= 0) return 0;
17674
17675 101436 int32_t ret = 0;
17676 101436 sprite *e=NULL;
17677
17678
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50006 times.
✓ Branch 4 taken 3942 times.
✓ Branch 5 taken 5196 times.
✓ Branch 6 taken 1825 times.
✓ Branch 7 taken 2765 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 11717 times.
✓ Branch 10 taken 5311 times.
✓ Branch 11 taken 4429 times.
✓ Branch 12 taken 998 times.
✓ Branch 13 taken 126 times.
✓ Branch 14 taken 618 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 420 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 730 times.
✓ Branch 21 taken 761 times.
✓ Branch 22 taken 7314 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2432 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 403 times.
✓ Branch 28 taken 292 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
101436 switch(guysbuf[id&0xFFF].family)
17679 {
17680 //Fixme: possible enemy memory leak. (minor)
17681 case eeWALK:
17682
3/6
✓ Branch 0 taken 50006 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50006 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50006 times.
✗ Branch 5 not taken.
50006 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17683 50006 break;
17684
17685 case eeLEV:
17686
3/6
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3942 times.
✗ Branch 5 not taken.
3942 e = new eLeever((zfix)x,(zfix)y,id,clk);
17687 3942 break;
17688
17689 case eeTEK:
17690
3/6
✓ Branch 0 taken 5196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5196 times.
✗ Branch 5 not taken.
5196 e = new eTektite((zfix)x,(zfix)y,id,clk);
17691 5196 break;
17692
17693 case eePEAHAT:
17694
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
1825 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17695 1825 break;
17696
17697 case eeZORA:
17698
3/6
✓ Branch 0 taken 2765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2765 times.
✗ Branch 5 not taken.
2765 e = new eZora((zfix)x,(zfix)y,id,clk);
17699 2765 break;
17700
17701 case eeGHINI:
17702
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17703 461 break;
17704
17705 case eeKEESE:
17706
3/6
✓ Branch 0 taken 11717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11717 times.
✗ Branch 5 not taken.
11717 e = new eKeese((zfix)x,(zfix)y,id,clk);
17707 11717 break;
17708
17709 case eeWIZZ:
17710
3/6
✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5311 times.
✗ Branch 5 not taken.
5311 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17711 5311 break;
17712
17713 case eePROJECTILE:
17714
3/6
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4429 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4429 times.
✗ Branch 5 not taken.
4429 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17715 4429 break;
17716
17717 case eeWALLM:
17718
3/6
✓ Branch 0 taken 998 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 998 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 998 times.
✗ Branch 5 not taken.
998 e = new eWallM((zfix)x,(zfix)y,id,clk);
17719 998 break;
17720
17721 case eeAQUA:
17722
3/6
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126 times.
✗ Branch 5 not taken.
126 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17723 126 break;
17724
17725 case eeMOLD:
17726
6/12
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 618 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 618 times.
✓ Branch 6 taken 618 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 618 times.
✓ Branch 10 taken 618 times.
✗ Branch 11 not taken.
618 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17727 618 break;
17728
17729 case eeMANHAN:
17730
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17731 149 break;
17732
17733 case eeGLEEOK:
17734
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17735 168 break;
17736
17737 case eeGHOMA:
17738
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17739 93 break;
17740
17741 case eeLANM:
17742
6/12
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 420 times.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 420 times.
✓ Branch 10 taken 420 times.
✗ Branch 11 not taken.
420 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17743 420 break;
17744
17745 case eeGANON:
17746
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17747 13 break;
17748
17749 case eeFAIRY:
17750
3/6
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 730 times.
✗ Branch 5 not taken.
730 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17751 730 break;
17752
17753 case eeFIRE:
17754
3/6
✓ Branch 0 taken 761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 761 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 761 times.
✗ Branch 5 not taken.
761 e = new eFire((zfix)x,(zfix)y,id,clk);
17755 761 break;
17756
17757 case eeOTHER:
17758
3/6
✓ Branch 0 taken 7314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7314 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7314 times.
✗ Branch 5 not taken.
7314 e = new eOther((zfix)x,(zfix)y,id,clk);
17759 7314 break;
17760
17761
17762 case eeSCRIPT01:
17763 case eeSCRIPT02:
17764 case eeSCRIPT03:
17765 case eeSCRIPT04:
17766 case eeSCRIPT05:
17767 case eeSCRIPT06:
17768 case eeSCRIPT07:
17769 case eeSCRIPT08:
17770 case eeSCRIPT09:
17771 case eeSCRIPT10:
17772 case eeSCRIPT11:
17773 case eeSCRIPT12:
17774 case eeSCRIPT13:
17775 case eeSCRIPT14:
17776 case eeSCRIPT15:
17777 case eeSCRIPT16:
17778 case eeSCRIPT17:
17779 case eeSCRIPT18:
17780 case eeSCRIPT19:
17781 case eeSCRIPT20:
17782 {
17783 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17784 {
17785 e = new eScript((zfix)x,(zfix)y,id,clk);
17786 break;
17787 }
17788 else return 0;
17789 }
17790
17791 case eeFFRIENDLY01:
17792 case eeFFRIENDLY02:
17793 case eeFFRIENDLY03:
17794 case eeFFRIENDLY04:
17795 case eeFFRIENDLY05:
17796 case eeFFRIENDLY06:
17797 case eeFFRIENDLY07:
17798 case eeFFRIENDLY08:
17799 case eeFFRIENDLY09:
17800 case eeFFRIENDLY10:
17801 {
17802 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17803 {
17804 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17805 }
17806 else return 0;
17807
17808 }
17809
17810 case eeSPINTILE:
17811
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17812 94 break;
17813
17814 // and these enemies use the misc10/misc2 value
17815 case eeROCK:
17816 {
17817
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17818 {
17819 case 1:
17820
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17821 30 break;
17822
17823 354 case 0:
17824 default:
17825
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17826 354 break;
17827 }
17828
17829 384 break;
17830 }
17831
17832 case eeTRAP:
17833 {
17834
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1600 times.
2432 switch(guysbuf[id&0xFFF].attributes[1])
17835 {
17836 case 1:
17837
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17838 832 break;
17839
17840 1600 case 0:
17841 default:
17842
3/6
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1600 times.
✗ Branch 5 not taken.
1600 e = new eTrap((zfix)x,(zfix)y,id,clk);
17843 1600 break;
17844 }
17845
17846 2432 break;
17847 }
17848
17849 case eeDONGO:
17850 {
17851
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].attributes[9])
17852 {
17853 case 1:
17854
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17855 48 break;
17856
17857 203 case 0:
17858 default:
17859
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17860 203 break;
17861 }
17862
17863 251 break;
17864 }
17865
17866 case eeDIG:
17867 {
17868
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 76 times.
403 switch(guysbuf[id&0xFFF].attributes[9])
17869 {
17870 case 1:
17871
3/6
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 327 times.
✗ Branch 5 not taken.
327 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17872 327 break;
17873
17874 76 case 0:
17875 default:
17876
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17877 76 break;
17878 }
17879
17880 403 break;
17881 }
17882
17883 case eePATRA:
17884 {
17885
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 102 times.
292 switch(guysbuf[id&0xFFF].attributes[9])
17886 {
17887 case 1:
17888
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17889 {
17890
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17891 102 break;
17892 }
17893 [[fallthrough]];
17894 190 case 0:
17895 default:
17896
3/6
✓ Branch 0 taken 190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 190 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 190 times.
✗ Branch 5 not taken.
190 e = new ePatra((zfix)x,(zfix)y,id,clk);
17897 190 break;
17898 }
17899
17900 292 break;
17901 }
17902
17903 case eeGUY:
17904 {
17905
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17906 {
17907 case 1:
17908 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17909 break;
17910
17911 5 case 0:
17912 default:
17913
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17914 5 break;
17915 }
17916
17917 5 break;
17918 }
17919
17920 case eeNONE:
17921
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17922 {
17923
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17924 533 break;
17925 break;
17926 }
17927 [[fallthrough]];
17928 default:
17929
17930 return 0;
17931 }
17932
17933 101436 ret++; // Made one enemy.
17934
17935
4/4
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 101305 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 106 times.
101436 if(z && canfall(id))
17936 {
17937 106 e->z = (zfix)z;
17938 106 }
17939
17940
2/2
✓ Branch 0 taken 101305 times.
✓ Branch 1 taken 131 times.
101436 ((enemy*)e)->ceiling = (z && canfall(id));
17941
17942
1/2
✓ Branch 0 taken 101436 times.
✗ Branch 1 not taken.
101436 if(!guys.add(e))
17943 {
17944 return 0;
17945 }
17946
17947 // add segments of segmented enemies
17948 101436 int32_t c=0;
17949
17950
6/6
✓ Branch 0 taken 99789 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 292 times.
101436 switch(guysbuf[id&0xFFF].family)
17951 {
17952 case eeMOLD:
17953 {
17954 618 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17955 618 id &= 0xFFF;
17956
17957
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3768 times.
✓ Branch 2 taken 3768 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3768 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 618 times.
3768 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17958 {
17959 //christ this is messy -DD
17960 3150 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17961
17962
4/8
✓ Branch 0 taken 3150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3150 times.
✗ Branch 7 not taken.
3150 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17963 {
17964 al_trace("Moldorm segment %d could not be created!\n",i+1);
17965
17966 for(int32_t j=0; j<i+1; j++)
17967 guys.del(guys.Count()-1);
17968
17969 return 0;
17970 }
17971
17972
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 2532 times.
3150 if(i>0)
17973 2532 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17974
17975 3150 ret++;
17976 3150 }
17977
17978 618 break;
17979 }
17980
17981 case eeLANM:
17982 {
17983 420 id &= 0xFFF;
17984 420 int32_t shft = guysbuf[id].attributes[1];
17985 420 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17986
17987
4/8
✓ Branch 0 taken 420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 420 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 420 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 420 times.
✗ Branch 7 not taken.
420 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17988 {
17989 al_trace("Lanmola segment 1 could not be created!\n");
17990 guys.del(guys.Count()-1);
17991 return 0;
17992 }
17993
17994 420 ret++;
17995
17996
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2267 times.
✓ Branch 2 taken 2267 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2267 times.
✓ Branch 6 taken 1847 times.
✓ Branch 7 taken 420 times.
2267 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17997 {
17998
4/8
✓ Branch 0 taken 1847 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1847 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1847 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1847 times.
✗ Branch 7 not taken.
1847 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17999 {
18000 al_trace("Lanmola segment %d could not be created!\n",i+1);
18001
18002 for(int32_t j=0; j<i+1; j++)
18003 guys.del(guys.Count()-1);
18004
18005 return 0;
18006 }
18007
18008 1847 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18009 1847 ret++;
18010 1847 }
18011 }
18012 420 break;
18013
18014 case eeMANHAN:
18015 149 id &= 0xFFF;
18016
18017
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
18018 {
18019
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18020 {
18021 al_trace("Manhandla head %d could not be created!\n",i+1);
18022
18023 for(int32_t j=0; j<i+1; j++)
18024 {
18025 guys.del(guys.Count()-1);
18026 }
18027
18028 return 0;
18029 }
18030
18031 688 ret++;
18032 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
18033 688 }
18034
18035 149 break;
18036
18037 case eeGLEEOK:
18038 {
18039 168 id &= 0xFFF;
18040 168 eGleeok* parent = (eGleeok*)e;
18041
18042
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
18043 {
18044
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
18045
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
18046 {
18047 al_trace("Gleeok head %d could not be created!\n",i+1);
18048
18049 for(int32_t j=0; j<i+1; j++)
18050 {
18051 guys.del(guys.Count()-1);
18052 }
18053
18054 return false;
18055 }
18056
18057 533 head->necktile=parent->necktile;
18058 533 head->dummy_int[1]=parent->necktile;
18059
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
18060 {
18061 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
18062 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
18063 421 }
18064 else
18065 {
18066 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
18067 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
18068 }
18069 533 head->tile = head->dummy_int[2];
18070
18071 533 c-=guysbuf[id].attributes[3];
18072 533 ret++;
18073 533 }
18074 }
18075 168 break;
18076
18077
18078 case eePATRA:
18079 {
18080 292 id &= 0xFFF;
18081 292 int32_t outeyes = 0;
18082
18083
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✓ Branch 2 taken 1956 times.
✓ Branch 3 taken 292 times.
2248 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
18084 {
18085
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1344 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1344 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1344 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1344 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1956 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18086 {
18087 al_trace("Patra outer eye %d could not be created!\n",i+1);
18088
18089 for(int32_t j=0; j<i+1; j++)
18090 guys.del(guys.Count()-1);
18091
18092 return 0;
18093 }
18094 else
18095 1956 outeyes++;
18096
18097 1956 ret++;
18098 1956 }
18099
18100
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 292 times.
604 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
18101 {
18102
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18103 {
18104 al_trace("Patra inner eye %d could not be created!\n",i+1);
18105
18106 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18107 guys.del(guys.Count()-1);
18108
18109 return 0;
18110 }
18111
18112 312 ret++;
18113 312 }
18114
18115 292 break;
18116 }
18117 }
18118
18119 101436 return ret;
18120 101436 }
18121
18122 1854532 bool isjumper(int32_t id)
18123 {
18124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1854532 times.
1854532 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18125 {
18126 return false;
18127 }
18128
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1750545 times.
✓ Branch 2 taken 103978 times.
1854532 switch(guysbuf[id&0xFFF].family)
18129 {
18130 case eeROCK:
18131 case eeTEK:
18132 9 return true;
18133
18134 case eeWALK:
18135
3/4
✓ Branch 0 taken 103978 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 91713 times.
103978 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
18136 91713 }
18137
18138 1842258 return false;
18139 1854532 }
18140
18141
18142 291817 bool isfixedtogrid(int32_t id)
18143 {
18144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291817 times.
291817 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18145 {
18146 return false;
18147 }
18148
1/2
✓ Branch 0 taken 291817 times.
✗ Branch 1 not taken.
291817 switch(guysbuf[id&0xFFF].family)
18149 {
18150 case eeWALK:
18151 case eeLEV:
18152 case eeZORA:
18153 case eeDONGO:
18154 case eeGANON:
18155 case eeROCK:
18156 case eeGLEEOK:
18157 case eeAQUA:
18158 case eeLANM:
18159 return true;
18160 }
18161
18162 291817 return false;
18163 291817 }
18164
18165 // Can't fall, can have Z value.
18166 51785071 bool isflier(int32_t id)
18167 {
18168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51785071 times.
51785071 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18169 {
18170 return false;
18171 }
18172
2/2
✓ Branch 0 taken 45356705 times.
✓ Branch 1 taken 6428366 times.
51785071 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
18173 {
18174 case eePEAHAT:
18175 case eeKEESE:
18176 case eePATRA:
18177 case eeFAIRY:
18178 case eeGHINI:
18179
18180 // Could theoretically have their Z set by a script
18181 case eeFIRE:
18182 6428366 return true;
18183 break;
18184 }
18185
18186 45356705 return false;
18187 51785071 }
18188
18189 // Can't have Z position
18190 3714963 bool never_in_air(int32_t id)
18191 {
18192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3714963 times.
3714963 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18193 {
18194 return false;
18195 }
18196
2/2
✓ Branch 0 taken 3705413 times.
✓ Branch 1 taken 9550 times.
3714963 switch(guysbuf[id&0xFFF].family)
18197 {
18198 case eeMANHAN:
18199 case eeMOLD:
18200 case eeLANM:
18201 case eeGLEEOK:
18202 case eeZORA:
18203 case eeLEV:
18204 case eeAQUA:
18205 case eeROCK:
18206 case eeGANON:
18207 case eeTRAP:
18208 case eePROJECTILE:
18209 case eeSPINTILE:
18210 9550 return true;
18211 }
18212
18213 3705413 return false;
18214 3714963 }
18215
18216 2015293 bool canfall(int32_t id)
18217 {
18218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2015293 times.
2015293 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18219 {
18220 return false;
18221 }
18222
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2015253 times.
✓ Branch 2 taken 40 times.
2015293 switch(guysbuf[id&0xFFF].family)
18223 {
18224 case eeGUY:
18225 {
18226
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
18227 40 return false;
18228
18229 switch(guysbuf[id&0xFFF].attributes[9])
18230 {
18231 case 1:
18232 case 2:
18233 return true;
18234
18235 case 0:
18236 case 3:
18237 default:
18238 return false;
18239 }
18240
18241 case eeGHOMA:
18242 case eeDIG:
18243 return false;
18244 }
18245 }
18246
18247
18248
4/4
✓ Branch 0 taken 2006817 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 152285 times.
✓ Branch 3 taken 1854532 times.
2015253 return !never_in_air(id) && !isflier(id) && !isjumper(id);
18249 2015293 }
18250
18251 73542396 bool enemy::enemycanfall(int32_t id, bool checkgrav)
18252 {
18253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73542396 times.
73542396 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18254 {
18255 return false;
18256 }
18257 //Z_scripterrlog("canfall family is %d:\n", family);
18258 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
18259 //if ( family == eeFIRE && id >= eSTART )
18260 //{
18261 // Z_scripterrlog("eeFire\n");
18262 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
18263 //}
18264
18265 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
18266
18267
3/3
✓ Branch 0 taken 428935 times.
✓ Branch 1 taken 71046567 times.
✓ Branch 2 taken 2066894 times.
73542396 switch(guysbuf[id&0xFFF].family)
18268 {
18269 case eeGUY:
18270 {
18271
1/2
✓ Branch 0 taken 2066894 times.
✗ Branch 1 not taken.
2066894 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18272 2066894 return false;
18273
18274 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
18275 {
18276 case 1:
18277 case 2:
18278 return true;
18279
18280 case 0:
18281 case 3:
18282 default:
18283 return false;
18284 }
18285
18286 case eeGHOMA:
18287 case eeDIG:
18288 428935 return false;
18289 }
18290 }
18291
18292
2/2
✓ Branch 0 taken 38947783 times.
✓ Branch 1 taken 32098784 times.
71046567 if(!checkgrav) return true;
18293 38947783 return (moveflags & move_obeys_grav);
18294
18295 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18296 // {
18297 // if ( moveflags & move_obeys_grav ) return true;
18298 // else return false;
18299 // }
18300 // else
18301 // {
18302 // return (moveflags & move_obeys_grav);
18303 // }
18304 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18305 73542396 }
18306
18307 1266 void addfires()
18308 {
18309
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 455 times.
1266 if(!get_qr(qr_NOGUYFIRES))
18310 {
18311 455 int32_t bs = get_qr(qr_BSZELDA);
18312 455 addguy(bs? 64: 72,64,gFIRE,-17,false,nullptr);
18313 455 addguy(bs?176:168,64,gFIRE,-18,false,nullptr);
18314 455 }
18315 1266 }
18316
18317 35264 void loadguys()
18318 {
18319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35264 times.
35264 if(loaded_guys)
18320 return;
18321
18322 35264 loaded_guys=true;
18323
18324 35264 byte Guy=0;
18325 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18326 // Else use mITEM and ipONETIME
18327 35264 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
18328 35264 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
18329
18330 35264 repaircharge=0;
18331 35264 adjustmagic=false;
18332 35264 learnslash=false;
18333
18334
2/2
✓ Branch 0 taken 105792 times.
✓ Branch 1 taken 35264 times.
141056 for(int32_t i=0; i<3; i++)
18335 {
18336 105792 prices[i]=0;
18337 105792 }
18338
18339 35264 hasitem=0;
18340
18341 35264 mapscr* guyscr = tmpscr;
18342
4/4
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 34360 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 429 times.
35264 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
18343 {
18344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
429 if(DMaps[currdmap].flags&dmfCAVES)
18345 {
18346 429 Guy=tmpscr[1].guy;
18347 429 guyscr = tmpscr+1;
18348 429 }
18349 429 }
18350 else
18351 {
18352 34835 Guy=tmpscr->guy;
18353
18354
4/4
✓ Branch 0 taken 34360 times.
✓ Branch 1 taken 475 times.
✓ Branch 2 taken 24138 times.
✓ Branch 3 taken 10222 times.
34835 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
18355 10222 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
18356 }
18357
18358 35264 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18359 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18360
4/4
✓ Branch 0 taken 3845 times.
✓ Branch 1 taken 31419 times.
✓ Branch 2 taken 2538 times.
✓ Branch 3 taken 1307 times.
35264 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
18361 {
18362
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1295 times.
1307 if(tmpscr->room==rZELDA)
18363 {
18364 12 addguy(120,72,Guy,-15,true,guyscr);
18365 12 guys.spr(0)->hxofs=1000;
18366 12 addenemy(128,96,eFIRE,-15);
18367 12 addenemy(112,96,eFIRE,-15);
18368 12 addenemy(96,120,eFIRE,-15);
18369 12 addenemy(144,120,eFIRE,-15);
18370 12 return;
18371 }
18372
18373
2/2
✓ Branch 0 taken 1291 times.
✓ Branch 1 taken 4 times.
2586 bool ffire = oldguy
18374
2/2
✓ Branch 0 taken 1266 times.
✓ Branch 1 taken 25 times.
1291 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18375 4 : (guyscr->roomflags&RFL_GUYFIRES);
18376
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1266 times.
1295 if(ffire)
18377 1266 addfires();
18378
18379
2/2
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 423 times.
1295 if(currscr>=128)
18380
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
436 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
18381 13 Guy=0;
18382
18383
4/6
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 1083 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1295 switch(tmpscr->room)
18384 {
18385 case rSP_ITEM:
18386 case rGRUMBLE:
18387 case rBOMBS:
18388 case rARROWS:
18389 case rSWINDLE:
18390 case rMUPGRADE:
18391 case rLEARNSLASH:
18392 case rTAKEONE:
18393
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 41 times.
166 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18394 55 Guy=0;
18395
18396 166 break;
18397
18398 case rREPAIR:
18399 if (get_qr(qr_OLD_DOORREPAIR)) break;
18400 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18401 Guy=0;
18402
18403 break;
18404 case rRP_HC:
18405 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18406 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18407 Guy=0;
18408
18409 break;
18410 case rMONEY:
18411
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18412 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18413 Guy=0;
18414
18415 break;
18416
18417 case rTRIFORCE:
18418 {
18419 45 int32_t tc = TriforceCount();
18420
18421
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18422 {
18423
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18424 10 Guy=0;
18425 9 }
18426 else
18427 {
18428
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18429 33 Guy=0;
18430 }
18431 }
18432 43 break;
18433 }
18434
18435
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1186 times.
1293 if(Guy)
18436 {
18437
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1157 times.
1186 if(ffire)
18438 1157 blockpath=true;
18439
18440
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 776 times.
1186 if(currscr<128)
18441 776 sfx(WAV_SCALE);
18442
18443
4/4
✓ Branch 0 taken 459 times.
✓ Branch 1 taken 727 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 355 times.
1186 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true,guyscr);
18444 1186 Hero.Freeze();
18445 1186 }
18446 1293 }
18447
5/6
✓ Branch 0 taken 32168 times.
✓ Branch 1 taken 1789 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 32097 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1789 times.
33957 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18448 {
18449 71 sfx(WAV_SCALE);
18450 71 addguy(120,62,Guy,-14,false,guyscr);
18451 71 }
18452
18453 35250 loaditem();
18454
18455 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18456 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18457
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 35231 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
35250 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
18458 {
18459 //setmapflag();
18460
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18461 150 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18462 15 }
18463 35262 }
18464
18465 35269 void loaditem()
18466 {
18467 35269 byte Item = 0;
18468
18469
2/2
✓ Branch 0 taken 34365 times.
✓ Branch 1 taken 904 times.
35269 if(currscr<128)
18470 {
18471 34365 Item=tmpscr->item;
18472
18473
4/4
✓ Branch 0 taken 1580 times.
✓ Branch 1 taken 32785 times.
✓ Branch 2 taken 31338 times.
✓ Branch 3 taken 3027 times.
34365 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
18474 {
18475
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 2968 times.
3027 if(tmpscr->flags8&fSECRETITEM)
18476 59 hasitem=8;
18477
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 1811 times.
2968 else if(tmpscr->flags&fITEM)
18478 1157 hasitem=1;
18479
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1747 times.
1811 else if(tmpscr->enemyflags&efCARRYITEM)
18480 64 hasitem=4; // Will be set to 2 by roaming_item
18481 else
18482
2/4
✓ Branch 0 taken 1747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1747 times.
✗ Branch 3 not taken.
3494 items.add(new item((zfix)tmpscr->itemx,
18483
6/12
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1732 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1747 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1747 times.
✗ Branch 11 not taken.
1747 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
18484
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1732 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1732 times.
✗ Branch 9 not taken.
1747 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18485
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1642 times.
1747 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
18486 1747 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18487 3027 }
18488 34365 }
18489
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 475 times.
904 else if(!(DMaps[currdmap].flags&dmfCAVES))
18490 {
18491
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
18492
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (currscr==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18493 {
18494 163 Item=tmpscr[1].catchall;
18495
18496
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18497
2/4
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
324 items.add(new item((zfix)tmpscr->itemx,
18498
3/12
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 162 times.
✗ Branch 11 not taken.
162 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
18499
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18500 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18501 163 }
18502 475 }
18503 35269 }
18504
18505 957 void never_return(int32_t index)
18506 {
18507
2/2
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 191 times.
957 if(!get_qr(qr_KILLALL))
18508 191 goto doit;
18509
18510
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 329 times.
2621 for(int32_t i=0; i<guys.Count(); i++)
18511
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 543 times.
✓ Branch 3 taken 437 times.
2292 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18512 {
18513 437 goto dontdoit;
18514 329 }
18515
18516 doit:
18517 520 setmapflag(mNEVERRET);
18518 dontdoit:
18519 957 return;
18520 }
18521
18522 63438 bool slowguy(int32_t id)
18523 {
18524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63438 times.
63438 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18525 {
18526 return false;
18527 }
18528 //return (guysbuf[id].step<100);
18529
2/2
✓ Branch 0 taken 53854 times.
✓ Branch 1 taken 9584 times.
63438 switch(id)
18530 {
18531 case eOCTO1S:
18532 case eOCTO2S:
18533 case eOCTO1F:
18534 case eOCTO2F:
18535 case eLEV1:
18536 case eLEV2:
18537 case eROCK:
18538 case eBOULDER:
18539 9584 return true;
18540 }
18541
18542 53854 return false;
18543 63438 }
18544
18545 82773 bool ok2add(int32_t id)
18546 {
18547
2/4
✓ Branch 0 taken 82773 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 82773 times.
82773 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
18548 {
18549 return false;
18550 }
18551
4/4
✓ Branch 0 taken 829 times.
✓ Branch 1 taken 81944 times.
✓ Branch 2 taken 464 times.
✓ Branch 3 taken 365 times.
82773 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18552 464 return false;
18553
18554
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 81668 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 201 times.
82309 switch(guysbuf[id].family)
18555 {
18556 // I added a special case for shooters because having traps on the same screen
18557 // was preventing them from spawning due to TMPNORET. This means they will
18558 // never stay dead, though, so it may not be the best solution. - Saf
18559 case eePROJECTILE:
18560 376 return true;
18561
18562
18563 case eeDIG:
18564 {
18565
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 75 times.
201 switch(guysbuf[id].attributes[9])
18566 {
18567 case 1:
18568
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18569 79 return !getmapflag(mTMPNORET);
18570
18571 47 return true;
18572
18573 75 case 0:
18574 default:
18575 75 return true;
18576 }
18577 }
18578 case eeGANON:
18579 case eeTRAP:
18580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18581
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18582 [[fallthrough]];
18583 default:
18584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81668 times.
81668 if (guysbuf[id].flags2&guy_ignoretmpnr) return true;
18585 81668 break;
18586 }
18587
18588
2/2
✓ Branch 0 taken 20881 times.
✓ Branch 1 taken 60787 times.
81668 if(!get_qr(qr_NOTMPNORET))
18589 60787 return !getmapflag(mTMPNORET);
18590
18591 20881 return true;
18592 82773 }
18593
18594 1408985 void activate_fireball_statue(int32_t pos)
18595 {
18596
3/4
✓ Branch 0 taken 287785 times.
✓ Branch 1 taken 1121200 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 287785 times.
1408985 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
18597 {
18598 1121200 return;
18599 }
18600
18601 287785 int32_t cx=-1000, cy=-1000;
18602 287785 int32_t x = (pos&15)<<4;
18603 287785 int32_t y = pos&0xF0;
18604
18605 287785 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
18606
18607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287785 times.
287785 if(!isfixedtogrid(statueID))
18608 {
18609
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 286277 times.
287785 if(ctype==cL_STATUE)
18610 {
18611 1508 cx=x+4;
18612 1508 cy=y+7;
18613 1508 }
18614
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 284962 times.
286277 else if(ctype==cR_STATUE)
18615 {
18616 1315 cx=x-8;
18617 1315 cy=y-1;
18618 1315 }
18619
2/2
✓ Branch 0 taken 283749 times.
✓ Branch 1 taken 1213 times.
284962 else if(ctype==cC_STATUE)
18620 {
18621 1213 cx=x;
18622 1213 cy=y;
18623 1213 }
18624 287785 }
18625 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18626 {
18627 cx=x;
18628 cy=y;
18629 }
18630
18631
2/2
✓ Branch 0 taken 283749 times.
✓ Branch 1 taken 4036 times.
287785 if(cx!=-1000) // No point creating it if this is false
18632 {
18633
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18634 {
18635
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18636 {
18637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18638 4 return; // No point deleting it. A script might be toying with it in some way.
18639 else
18640 guys.del(j);
18641 }
18642 9750 }
18643
18644 4032 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18645 4032 }
18646 1408985 }
18647
18648 34961 void activate_fireball_statues()
18649 {
18650
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 33548 times.
34961 if(!(tmpscr->enemyflags&efFIREBALLS))
18651 {
18652 33548 return;
18653 }
18654
18655
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 248688 times.
250101 for(int32_t i=0; i<176; i++)
18656 {
18657 248688 activate_fireball_statue(i);
18658 248688 }
18659 34961 }
18660
18661 34961 void load_default_enemies()
18662 {
18663 34961 wallm_load_clk=frame-80;
18664
18665
2/2
✓ Branch 0 taken 33081 times.
✓ Branch 1 taken 1880 times.
34961 if(tmpscr->enemyflags&efZORA)
18666 {
18667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1880 times.
1880 if(zoraID>=0)
18668 1880 addenemy(-16, -16, zoraID, 0);
18669 1880 }
18670
18671
2/2
✓ Branch 0 taken 34783 times.
✓ Branch 1 taken 178 times.
34961 if(tmpscr->enemyflags&efTRAP4)
18672 {
18673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178 times.
178 if(cornerTrapID>=0)
18674 {
18675 178 addenemy(32, 32, cornerTrapID, -14);
18676 178 addenemy(208, 32, cornerTrapID, -14);
18677 178 addenemy(32, 128, cornerTrapID, -14);
18678 178 addenemy(208, 128, cornerTrapID, -14);
18679 178 }
18680 178 }
18681
18682
2/2
✓ Branch 0 taken 384571 times.
✓ Branch 1 taken 34961 times.
419532 for(int32_t y=0; y<176; y+=16)
18683 {
18684
2/2
✓ Branch 0 taken 6153136 times.
✓ Branch 1 taken 384571 times.
6537707 for(int32_t x=0; x<256; x+=16)
18685 {
18686 6153136 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
18687 6153136 int32_t cflag = MAPFLAG(x, y);
18688 6153136 int32_t cflag_i = MAPCOMBOFLAG(x, y);
18689
18690
4/6
✓ Branch 0 taken 6153136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6152830 times.
✓ Branch 3 taken 306 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6152830 times.
6153136 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18691 {
18692
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 296 times.
306 if(trapLOSHorizontalID>=0)
18693 296 addenemy(x, y, trapLOSHorizontalID, -14);
18694 306 }
18695
4/6
✓ Branch 0 taken 6152830 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6152624 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6152624 times.
6152830 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18696 {
18697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(trapLOSVerticalID>=0)
18698 206 addenemy(x, y, trapLOSVerticalID, -14);
18699 206 }
18700
4/6
✓ Branch 0 taken 6152624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6152346 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6152346 times.
6152624 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18701 {
18702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18703 {
18704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(addenemy(x, y, trapLOS4WayID, -14))
18705 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18706 278 }
18707 278 }
18708
18709
4/6
✓ Branch 0 taken 6152346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6151947 times.
✓ Branch 3 taken 399 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6151947 times.
6152346 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18710 {
18711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(trapConstantHorizontalID>=0)
18712 399 addenemy(x, y, trapConstantHorizontalID, -14);
18713 399 }
18714
4/6
✓ Branch 0 taken 6151947 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6151514 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6151514 times.
6151947 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18715 {
18716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
18717 433 addenemy(x, y, trapConstantVerticalID, -14);
18718 433 }
18719
18720
1/2
✓ Branch 0 taken 6153136 times.
✗ Branch 1 not taken.
6153136 if(ctype==cSPINTILE1)
18721 {
18722 // Awaken spinning tile
18723 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
18724 }
18725 6153136 }
18726 384571 }
18727
18728
2/2
✓ Branch 0 taken 34905 times.
✓ Branch 1 taken 56 times.
34961 if(tmpscr->enemyflags&efTRAP2)
18729 {
18730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(centerTrapID>=-1)
18731 {
18732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(addenemy(64, 80, centerTrapID, -14))
18733 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18734
18735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(addenemy(176, 80, centerTrapID, -14))
18736 56 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18737 56 }
18738 56 }
18739
18740
2/2
✓ Branch 0 taken 34878 times.
✓ Branch 1 taken 83 times.
34961 if(tmpscr->enemyflags&efROCKS)
18741 {
18742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18743 {
18744 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18745 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18746 83 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
18747 83 }
18748 83 }
18749
18750 34961 activate_fireball_statues();
18751 34961 }
18752
18753 44621178 void update_slope_combopos(int32_t lyr, int32_t pos)
18754 {
18755
2/4
✓ Branch 0 taken 44621178 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 44621178 times.
44621178 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
18756 44621178 mapscr* s = FFCore.tempScreens[lyr];
18757 44621178 newcombo const& cmb = combobuf[s->data[pos]];
18758
18759 44621178 auto id = (176*lyr)+pos;
18760 44621178 auto it = slopes.find(id);
18761
18762 44621178 bool wasSlope = it!=slopes.end();
18763 44621178 bool isSlope = cmb.type == cSLOPE;
18764
18765
3/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 44620975 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 203 times.
44621178 if(isSlope && !wasSlope)
18766 {
18767 203 slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos);
18768 203 }
18769
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44620975 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44620975 else if(wasSlope && !isSlope)
18770 {
18771 slopes.erase(it);
18772 }
18773 44621178 }
18774 35336 void update_slope_comboposes()
18775 {
18776
2/2
✓ Branch 0 taken 247352 times.
✓ Branch 1 taken 35336 times.
282688 for(auto lyr = 0; lyr < 7; ++lyr)
18777 {
18778
2/2
✓ Branch 0 taken 43533952 times.
✓ Branch 1 taken 247352 times.
43781304 for(auto pos = 0; pos < 176; ++pos)
18779 43533952 update_slope_combopos(lyr,pos);
18780 247352 }
18781 35336 }
18782
18783 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18784 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
18785 1160297 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
18786 {
18787 1160297 delete_fireball_shooter(s, pos);
18788 1160297 }
18789
18790 //Placeholder in case we need it.
18791 void screen_ffc_modify_preroutine(word index)
18792 {
18793 return;
18794 }
18795
18796 // Everything that must be done after we change a screen's combo to another combo. -L
18797 1160297 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
18798 {
18799 1160297 s->valid |= mVALID;
18800 1160297 activate_fireball_statue(pos);
18801
18802
2/2
✓ Branch 0 taken 1160203 times.
✓ Branch 1 taken 94 times.
1160297 if(combobuf[s->data[pos]].type==cSPINTILE1)
18803 {
18804 // Awaken spinning tile
18805 94 awaken_spinning_tile(s,pos);
18806 94 }
18807 1160297 int32_t lyr = -1;
18808
2/2
✓ Branch 0 taken 118155 times.
✓ Branch 1 taken 1042142 times.
1160297 if(s == tmpscr) lyr = 0;
18809
2/2
✓ Branch 0 taken 73071 times.
✓ Branch 1 taken 593895 times.
666966 else for(size_t q = 0; q < 6; ++q)
18810 {
18811
2/2
✓ Branch 0 taken 45084 times.
✓ Branch 1 taken 548811 times.
593895 if(s == tmpscr2+q)
18812 {
18813 45084 lyr = q+1;
18814 45084 break;
18815 }
18816 548811 }
18817
2/2
✓ Branch 0 taken 73071 times.
✓ Branch 1 taken 1087226 times.
1160297 if(lyr > -1)
18818 1087226 update_slope_combopos(lyr,pos);
18819 1160297 }
18820
18821 8797022 void screen_ffc_modify_postroutine(word index)
18822 {
18823 8797022 ffcdata& ff = tmpscr->ffcs[index];
18824 8797022 newcombo const& cmb = combobuf[ff.data];
18825
18826 8797022 auto id = (176*7)+int32_t(index);
18827 8797022 auto it = slopes.find(id);
18828
18829 8797022 bool wasSlope = it!=slopes.end();
18830
1/2
✓ Branch 0 taken 8797022 times.
✗ Branch 1 not taken.
8797022 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffc_changer);
18831
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8797022 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8797022 if(isSlope && !wasSlope)
18832 {
18833 slopes.try_emplace(id, nullptr, &ff, id);
18834 }
18835
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8797022 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8797022 else if(wasSlope && !isSlope)
18836 {
18837 slopes.erase(it);
18838 }
18839
18840 8797022 tmpscr->ffcCountMarkDirty();
18841 8797022 }
18842
18843 4404 void screen_combo_modify_pre(int32_t cid)
18844 {
18845
2/2
✓ Branch 0 taken 30828 times.
✓ Branch 1 taken 4404 times.
35232 for(auto lyr = 0; lyr < 7; ++lyr)
18846 {
18847 30828 mapscr* t = FFCore.tempScreens[lyr];
18848
2/2
✓ Branch 0 taken 5425728 times.
✓ Branch 1 taken 30828 times.
5456556 for(int32_t i = 0; i < 176; i++)
18849 {
18850
2/2
✓ Branch 0 taken 5419127 times.
✓ Branch 1 taken 6601 times.
5425728 if(t->data[i] == cid)
18851 {
18852 6601 screen_combo_modify_preroutine(t,i);
18853 6601 }
18854 5425728 }
18855 30828 }
18856 4404 }
18857 4404 void screen_combo_modify_post(int32_t cid)
18858 {
18859
2/2
✓ Branch 0 taken 30828 times.
✓ Branch 1 taken 4404 times.
35232 for(auto lyr = 0; lyr < 7; ++lyr)
18860 {
18861 30828 mapscr* t = FFCore.tempScreens[lyr];
18862
2/2
✓ Branch 0 taken 5425728 times.
✓ Branch 1 taken 30828 times.
5456556 for(int32_t i = 0; i < 176; i++)
18863 {
18864
2/2
✓ Branch 0 taken 5419127 times.
✓ Branch 1 taken 6601 times.
5425728 if(t->data[i] == cid)
18865 {
18866 6601 screen_combo_modify_postroutine(t,i);
18867 6601 }
18868 5425728 }
18869 30828 }
18870
2/2
✓ Branch 0 taken 563712 times.
✓ Branch 1 taken 4404 times.
568116 for(word ind = 0; ind < MAXFFCS; ++ind)
18871 {
18872
2/2
✓ Branch 0 taken 563462 times.
✓ Branch 1 taken 250 times.
563712 if(tmpscr->ffcs[ind].data == cid)
18873 250 screen_ffc_modify_postroutine(ind);
18874 563712 }
18875 4404 }
18876
18877 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
18878 {
18879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
18880 94 }
18881
18882
18883 // It stands for next_side_pos
18884 11436 void nsp(bool random)
18885 // moves sle_x and sle_y to the next position
18886 {
18887
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8175 times.
11436 if(random)
18888 {
18889
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18890 {
18891 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18892 1634 sle_y = (zc_oldrand()%10)*16;
18893 1634 }
18894 else
18895 {
18896 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18897 1627 sle_x = (zc_oldrand()%15)*16;
18898 }
18899
18900 3261 return;
18901 }
18902
18903
2/2
✓ Branch 0 taken 6151 times.
✓ Branch 1 taken 2024 times.
8175 if(sle_x==0)
18904 {
18905
2/2
✓ Branch 0 taken 1845 times.
✓ Branch 1 taken 179 times.
2024 if(sle_y<160)
18906 1845 sle_y+=16;
18907 else
18908 179 sle_x+=16;
18909 2024 }
18910
2/2
✓ Branch 0 taken 2581 times.
✓ Branch 1 taken 3570 times.
6151 else if(sle_y==160)
18911 {
18912
2/2
✓ Branch 0 taken 2416 times.
✓ Branch 1 taken 165 times.
2581 if(sle_x<240)
18913 2416 sle_x+=16;
18914 else
18915 165 sle_y-=16;
18916 2581 }
18917
2/2
✓ Branch 0 taken 1550 times.
✓ Branch 1 taken 2020 times.
3570 else if(sle_x==240)
18918 {
18919
2/2
✓ Branch 0 taken 1402 times.
✓ Branch 1 taken 148 times.
1550 if(sle_y>0)
18920 1402 sle_y-=16;
18921 else
18922 148 sle_x-=16;
18923 1550 }
18924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18925 {
18926
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18927 2020 sle_x-=16;
18928 else
18929 sle_y+=16;
18930 2020 }
18931 11436 }
18932
18933 2426 int32_t next_side_pos(bool random)
18934 // moves sle_x and sle_y to the next available position
18935 // returns the direction the enemy should face
18936 {
18937 bool blocked;
18938 2426 int32_t c=0;
18939
18940 2426 do
18941 {
18942
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11305 times.
11436 nsp(c>35 ? false : random);
18943
4/4
✓ Branch 0 taken 2444 times.
✓ Branch 1 taken 8992 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2425 times.
13861 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
18944
1/2
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
2425 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
18945
2/4
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2425 times.
✗ Branch 3 not taken.
2425 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
18946
2/4
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2425 times.
2425 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
18947 2425 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
18948
18949
2/2
✓ Branch 0 taken 11435 times.
✓ Branch 1 taken 1 times.
11436 if(++c>50)
18950 1 return -1;
18951
2/2
✓ Branch 0 taken 9010 times.
✓ Branch 1 taken 2425 times.
11435 }
18952 11435 while(blocked);
18953
18954 2425 int32_t dir=0;
18955
18956
2/2
✓ Branch 0 taken 1690 times.
✓ Branch 1 taken 735 times.
2425 if(sle_x==0) dir=right;
18957
18958
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 569 times.
2425 if(sle_y==0) dir=down;
18959
18960
2/2
✓ Branch 0 taken 1719 times.
✓ Branch 1 taken 706 times.
2425 if(sle_x==240) dir=left;
18961
18962
1/2
✓ Branch 0 taken 2425 times.
✗ Branch 1 not taken.
2425 if(sle_y==168) dir=up;
18963
18964 2425 return dir;
18965 2426 }
18966
18967 bool can_side_load(int32_t id)
18968 {
18969 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18970 {
18971 return false;
18972 }
18973 switch(guysbuf[id].family) //id&0x0FFF)
18974 {
18975 //case eTEK1:
18976 //case eTEK2:
18977 //case eTEK3:
18978 //case eLEV1:
18979 //case eLEV2:
18980 //case eLEV3:
18981 //case eRAQUAM:
18982 //case eLAQUAM:
18983 //case eDODONGO:
18984 //case eMANHAN:
18985 //case eGLEEOK1:
18986 //case eGLEEOK2:
18987 //case eGLEEOK3:
18988 //case eGLEEOK4:
18989 //case eDIG1:
18990 //case eDIG3:
18991 //case eGOHMA1:
18992 //case eGOHMA2:
18993 //case eCENT1:
18994 //case eCENT2:
18995 //case ePATRA1:
18996 //case ePATRA2:
18997 //case eGANON:
18998 //case eMANHAN2:
18999 //case eCEILINGM: later
19000 //case eFLOORM: later
19001 //case ePATRABS:
19002 //case ePATRAL2:
19003 //case ePATRAL3:
19004 //case eGLEEOK1F:
19005 //case eGLEEOK2F:
19006 //case eGLEEOK3F:
19007 //case eGLEEOK4F:
19008 //case eDODONGOBS:
19009 //case eDODONGOF:
19010 //case eGOHMA3:
19011 //case eGOHMA4:
19012 //case eSHOOTMAGIC:
19013 //case eSHOOTROCK:
19014 //case eSHOOTSPEAR:
19015 //case eSHOOTSWORD:
19016 //case eSHOOTFLAME:
19017 //case eSHOOTFLAME2:
19018 //case eSHOOTFBALL:
19019 case eeTEK:
19020 case eeLEV:
19021 case eeAQUA:
19022 case eeDONGO:
19023 case eeMANHAN:
19024 case eeGLEEOK:
19025 case eeDIG:
19026 case eeGHOMA:
19027 case eeLANM:
19028 case eePATRA:
19029 case eeGANON:
19030 case eePROJECTILE:
19031 return false;
19032 break;
19033 }
19034
19035 return true;
19036 }
19037
19038 static bool script_sle = false;
19039 static int32_t sle_pattern = 0;
19040 void script_side_load_enemies()
19041 {
19042 if(script_sle || sle_clk) return;
19043 sle_cnt = 0;
19044 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19045 ++sle_cnt;
19046 script_sle = true;
19047 sle_pattern = tmpscr->pattern;
19048 sle_clk = 0;
19049 }
19050
19051 54442 void side_load_enemies()
19052 {
19053
3/4
✓ Branch 0 taken 54442 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53760 times.
✓ Branch 3 taken 682 times.
54442 if(!script_sle && sle_clk==0)
19054 {
19055 682 sle_pattern = tmpscr->pattern;
19056 682 sle_cnt = 0;
19057 682 int32_t guycnt = 0;
19058 682 int16_t s = (currmap<<7)+currscr;
19059 682 bool beenhere=false;
19060 682 bool reload=true;
19061 682 bool unbeatablereload = true;
19062
19063 682 load_default_enemies();
19064
19065
2/2
✓ Branch 0 taken 4092 times.
✓ Branch 1 taken 682 times.
4774 for(int32_t i=0; i<6; i++)
19066
2/2
✓ Branch 0 taken 3889 times.
✓ Branch 1 taken 203 times.
4295 if(visited[i]==s)
19067 203 beenhere=true;
19068
19069
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 479 times.
682 if(!beenhere)
19070 {
19071 479 visited[vhead]=s;
19072 479 vhead = (vhead+1)%6;
19073 479 }
19074
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 42 times.
203 else if(game->guys[s]==0)
19075 {
19076 42 sle_cnt=0;
19077 42 reload=false;
19078 42 }
19079
19080
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 640 times.
682 if(reload)
19081 {
19082 640 sle_cnt = game->guys[s];
19083
19084
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 640 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 220 times.
640 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
19085 640 || sle_cnt==0)
19086 {
19087
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1267 times.
✓ Branch 2 taken 1050 times.
✓ Branch 3 taken 220 times.
1270 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19088 1050 ++sle_cnt;
19089 220 }
19090
3/4
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 479 times.
✗ Branch 3 not taken.
640 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19091 {
19092 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
19093 {
19094 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesnt_count))
19095 {
19096 unbeatablereload = false;
19097 }
19098 }
19099 if (unbeatablereload)
19100 {
19101 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19102 {
19103 ++sle_cnt;
19104 }
19105 }
19106 }
19107 640 }
19108
19109
3/4
✓ Branch 0 taken 651 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 651 times.
682 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
19110 {
19111 31 sle_cnt = 0;
19112
19113
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19114 108 ++sle_cnt;
19115 31 }
19116
19117
2/2
✓ Branch 0 taken 2442 times.
✓ Branch 1 taken 682 times.
3124 for(int32_t i=0; i<sle_cnt; i++)
19118 2442 ++guycnt;
19119
19120 682 game->guys[s] = guycnt;
19121 682 }
19122
19123
2/2
✓ Branch 0 taken 52016 times.
✓ Branch 1 taken 2426 times.
54442 if((++sle_clk+8)%24 == 0)
19124 {
19125 2426 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
19126
19127
4/4
✓ Branch 0 taken 2425 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 232 times.
✓ Branch 3 taken 2193 times.
2426 if(dir==-1 || tooclose(sle_x,sle_y,32))
19128 {
19129 233 return;
19130 }
19131
19132 2193 int32_t enemy_slot=guys.Count();
19133
19134
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2193 times.
2193 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
19135 sle_cnt--;
19136
19137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if(sle_cnt > 0)
19138 {
19139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
19140 {
19141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2193 times.
2193 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
19142 {
19143 2193 guys.spr(enemy_slot)->dir = dir;
19144 2193 }
19145
1/2
✓ Branch 0 taken 2193 times.
✗ Branch 1 not taken.
2193 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19146 {
19147 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19148 {
19149 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
19150 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
19151 }
19152 }
19153 2193 }
19154 2193 }
19155 2193 }
19156
19157
2/2
✓ Branch 0 taken 53631 times.
✓ Branch 1 taken 578 times.
54209 if(sle_cnt<=0)
19158 {
19159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if(script_sle)
19160 script_sle = false;
19161 578 else loaded_enemies=true;
19162 578 sle_clk = 0;
19163 578 }
19164 54442 }
19165
19166 1208111 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
19167 {
19168
19169
4/4
✓ Branch 0 taken 1105227 times.
✓ Branch 1 taken 102884 times.
✓ Branch 2 taken 102884 times.
✓ Branch 3 taken 1208111 times.
1208111 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
19170 {
19171 205768 return false; //never 0, never OoB.
19172 }
19173 // No corner enemies
19174
6/6
✓ Branch 0 taken 1042351 times.
✓ Branch 1 taken 165760 times.
✓ Branch 2 taken 40016 times.
✓ Branch 3 taken 1082367 times.
✓ Branch 4 taken 114320 times.
✓ Branch 5 taken 91456 times.
1208111 if((x==0 || x==240) && (y==0 || y==160))
19175
19176 205776 return false;
19177
19178 //Is a no spawn combo...
19179
4/4
✓ Branch 0 taken 1082355 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1082359 times.
1082367 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19180 16 return false;
19181
19182 // No enemies in dungeon walls
19183
10/10
✓ Branch 0 taken 655073 times.
✓ Branch 1 taken 427286 times.
✓ Branch 2 taken 582513 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 509953 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 422881 times.
✓ Branch 7 taken 87072 times.
✓ Branch 8 taken 87072 times.
✓ Branch 9 taken 335809 times.
1082359 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
19184 319264 return false;
19185
19186 // Too close
19187
4/4
✓ Branch 0 taken 74233 times.
✓ Branch 1 taken 688862 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 74132 times.
763095 if(tooclose(x,y,40) && t<11)
19188 74132 return false;
19189
19190 // Can't fly onto it?
19191
4/4
✓ Branch 0 taken 122271 times.
✓ Branch 1 taken 566692 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 17932 times.
742855 if(isflier(tmpscr->enemy[i])&&
19192
2/2
✓ Branch 0 taken 121881 times.
✓ Branch 1 taken 390 times.
122271 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
19193
2/2
✓ Branch 0 taken 53892 times.
✓ Branch 1 taken 67989 times.
121881 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19194 18322 return false;
19195
19196 // Can't jump onto it?
19197 if
19198 (
19199
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 86588 times.
757233 guysbuf[tmpscr->enemy[i]].family==eeTEK
19200
19201
2/2
✓ Branch 0 taken 86606 times.
✓ Branch 1 taken 584035 times.
670641 &&
19202 (
19203
2/2
✓ Branch 0 taken 86599 times.
✓ Branch 1 taken 7 times.
86606 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19204
2/2
✓ Branch 0 taken 86598 times.
✓ Branch 1 taken 1 times.
86599 COMBOTYPE(x+8,y+8)==cNOENEMY||
19205
1/2
✓ Branch 0 taken 86598 times.
✗ Branch 1 not taken.
86598 ispitfall(x+8,y+8)||
19206
2/2
✓ Branch 0 taken 86592 times.
✓ Branch 1 taken 6 times.
86598 MAPFLAG(x+8,y+8)==mfNOENEMY||
19207 86592 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19208 )
19209 )
19210 {
19211 18 return false;
19212 }
19213
19214 // Other off-limit combos
19215
6/6
✓ Branch 0 taken 566670 times.
✓ Branch 1 taken 103953 times.
✓ Branch 2 taken 480082 times.
✓ Branch 3 taken 86588 times.
✓ Branch 4 taken 263616 times.
✓ Branch 5 taken 216466 times.
1150705 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
19216
2/2
✓ Branch 0 taken 268958 times.
✓ Branch 1 taken 211124 times.
480082 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
19217 480082 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
19218 216466 return false;
19219
19220 // Don't ever generate enemies on these combos!
19221
4/4
✓ Branch 0 taken 453853 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 453859 times.
454157 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19222 310 return false;
19223
19224 //BS Dodongos need at least 2 spaces.
19225
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 452820 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
453859 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].attributes[9] ==1))
19226 {
19227
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19228
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19229
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19230 ((y>144)||_walkflag(x, y+24,2)))
19231 {
19232 return false;
19233 }
19234 19 }
19235
19236 453853 return true;
19237 1105227 }
19238
19239 159462 bool is_ceiling_pattern(int32_t i)
19240 {
19241
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 159442 times.
159462 return (i==pCEILING || i==pCEILINGR);
19242 }
19243
19244 5716 int32_t placeenemy(int32_t i)
19245 {
19246 5716 std::map<int32_t, int32_t> freeposcache;
19247 5716 int32_t frees = 0;
19248
19249
2/2
✓ Branch 0 taken 62876 times.
✓ Branch 1 taken 5716 times.
68592 for(int32_t y=0; y<176; y+=16)
19250 {
19251
2/2
✓ Branch 0 taken 1006016 times.
✓ Branch 1 taken 62876 times.
1068892 for(int32_t x=0; x<256; x+=16)
19252 {
19253
3/4
✓ Branch 0 taken 1006016 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 396120 times.
✓ Branch 3 taken 609896 times.
1006016 if(is_starting_pos(i,x,y,0))
19254 {
19255
1/2
✓ Branch 0 taken 396120 times.
✗ Branch 1 not taken.
396120 freeposcache[frees++] = (y&0xF0)+(x>>4);
19256 396120 }
19257 1006016 }
19258 62876 }
19259
19260
2/2
✓ Branch 0 taken 5705 times.
✓ Branch 1 taken 11 times.
5716 if(frees > 0)
19261
2/4
✓ Branch 0 taken 5705 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5705 times.
✗ Branch 3 not taken.
5705 return freeposcache[zc_oldrand()%frees];
19262
19263 11 return -1;
19264 5716 }
19265
19266 80542 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
19267 {
19268 80542 bool placed=false;
19269 80542 int32_t t=-1;
19270
19271 // First: enemy combo flags
19272
2/2
✓ Branch 0 taken 800202 times.
✓ Branch 1 taken 63449 times.
863651 for(int32_t sy=0; sy<176; sy+=16)
19273 {
19274
2/2
✓ Branch 0 taken 12675979 times.
✓ Branch 1 taken 783109 times.
13459088 for(int32_t sx=0; sx<256; sx+=16)
19275 {
19276 12675979 int32_t cflag = MAPFLAG(sx, sy);
19277 12675979 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
19278
19279
2/4
✓ Branch 0 taken 12675979 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12675979 times.
✗ Branch 3 not taken.
12675979 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19280 {
19281 if(!ok2add(tmpscr->enemy[i]))
19282 {
19283 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19284 }
19285 else
19286 {
19287 addenemy(sx,
19288 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19289 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19290
19291 ++guycnt;
19292
19293 placed=true;
19294 goto placed_enemy;
19295 }
19296 }
19297
19298
4/4
✓ Branch 0 taken 12658837 times.
✓ Branch 1 taken 17142 times.
✓ Branch 2 taken 12658837 times.
✓ Branch 3 taken 17142 times.
12675979 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19299 {
19300
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17093 times.
17142 if(!ok2add(tmpscr->enemy[i]))
19301 {
19302
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19303 49 }
19304 else
19305 {
19306 34186 addenemy(sx,
19307
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17092 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17093 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19308
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17093 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19309
19310 17093 ++guycnt;
19311
19312 17093 placed=true;
19313 17093 goto placed_enemy;
19314 }
19315 49 }
19316 12658886 }
19317 783109 }
19318
19319 // Next: enemy pattern
19320
6/8
✓ Branch 0 taken 4939 times.
✓ Branch 1 taken 58510 times.
✓ Branch 2 taken 57954 times.
✓ Branch 3 taken 5495 times.
✓ Branch 4 taken 57954 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 57954 times.
63449 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
19321 {
19322 57954 do
19323 {
19324
19325 // NES positions
19326 99432 pos%=9;
19327 99432 x=stx[loadside][pos];
19328 99432 y=sty[loadside][pos];
19329 99432 ++pos;
19330 99432 ++t;
19331
2/2
✓ Branch 0 taken 41478 times.
✓ Branch 1 taken 57954 times.
157386 }
19332
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 99211 times.
99432 while((t< 20) && !is_starting_pos(i,x,y,t));
19333 57954 }
19334
19335
4/4
✓ Branch 0 taken 57954 times.
✓ Branch 1 taken 5495 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 57733 times.
63449 if(t<0 || t >= 20) // above enemy pattern failed
19336 {
19337 // Final chance: find a random position anywhere onscreen
19338 5716 int32_t randpos = placeenemy(i);
19339
19340
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5705 times.
5716 if(randpos>-1)
19341 {
19342 5705 x=(randpos&15)<<4;
19343 5705 y= randpos&0xF0;
19344 5705 }
19345 else // All opportunities failed - abort
19346 {
19347 11 return;
19348 }
19349 5705 }
19350
19351 {
19352 63438 int32_t c=0;
19353 63438 c=clk;
19354
19355
2/2
✓ Branch 0 taken 9584 times.
✓ Branch 1 taken 53854 times.
63438 if(!slowguy(tmpscr->enemy[i]))
19356 53854 ++fastguys;
19357
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 7998 times.
9584 else if(fastguys>0)
19358 1586 c=-15*(i-fastguys+2);
19359 else
19360 7998 c=-15*(i+1);
19361
19362
4/6
✓ Branch 0 taken 28861 times.
✓ Branch 1 taken 34577 times.
✓ Branch 2 taken 28861 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 28861 times.
63438 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19363 {
19364 // Special case for blue leevers
19365
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 26967 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 1133 times.
28861 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].attributes[0]==1)
19366 761 c=-15*(i+1);
19367 else
19368 28100 c=-15;
19369 28861 }
19370
19371
2/2
✓ Branch 0 taken 62638 times.
✓ Branch 1 taken 800 times.
63438 if(!ok2add(tmpscr->enemy[i]))
19372 {
19373
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 670 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
800 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19374 800 }
19375 else
19376 {
19377
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62638 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62638 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19378 {
19379
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 62508 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
125276 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19380
3/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 62508 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 130 times.
62638 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
19381
19382 62638 ++guycnt;
19383 62638 }
19384 }
19385
19386 63438 placed=true;
19387 63438 } // if(t < 20)
19388
19389 placed_enemy:
19390
19391 // I don't like this, but it seems to work...
19392 static bool foundCarrier;
19393
19394
2/2
✓ Branch 0 taken 59157 times.
✓ Branch 1 taken 21374 times.
80531 if(i==0)
19395 21374 foundCarrier=false;
19396
19397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80531 times.
80531 if(placed)
19398 {
19399
4/4
✓ Branch 0 taken 21374 times.
✓ Branch 1 taken 59157 times.
✓ Branch 2 taken 21205 times.
✓ Branch 3 taken 169 times.
80531 if(i==0 && tmpscr->enemyflags&efLEADER)
19400 {
19401 169 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19402
19403
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if(index!=-1)
19404 {
19405 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19406
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
19407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if(index!=-1)
19408 {
19409 162 ((enemy*)guys.spr(index))->leader = true;
19410 162 }
19411 162 }
19412 169 }
19413
19414
4/4
✓ Branch 0 taken 80308 times.
✓ Branch 1 taken 223 times.
✓ Branch 2 taken 80244 times.
✓ Branch 3 taken 64 times.
80531 if(!foundCarrier && hasitem&(4|2))
19415 {
19416 64 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19417
19418
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesnt_count)==0)
19419 {
19420 64 ((enemy*)guys.spr(index))->itemguy = true;
19421 64 foundCarrier=true;
19422 64 }
19423 64 }
19424 80531 }
19425 80542 }
19426
19427 bool scriptloadenemies()
19428 {
19429 loaded_enemies = true;
19430 if(script_sle || sle_clk) return false;
19431 if(tmpscr->pattern==pNOSPAWN) return false;
19432
19433 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19434 {
19435 script_side_load_enemies();
19436 return true;
19437 }
19438
19439 int32_t pos=zc_oldrand()%9;
19440 int32_t clk=-15,x=0,y=0,fastguys=0;
19441 int32_t i=0,guycnt=0;
19442 int32_t loadcnt = 10;
19443
19444 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19445 {
19446 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19447 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19448 if (guys.Count() > preguycount)
19449 {
19450 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19451 {
19452 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19453 {
19454 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19455 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19456 }
19457 }
19458 }
19459 --clk;
19460 }
19461 return true;
19462 }
19463
19464 14130987 void loadenemies()
19465 {
19466
3/4
✓ Branch 0 taken 14130987 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53760 times.
✓ Branch 3 taken 14077227 times.
14130987 if(script_sle || sle_clk)
19467 {
19468 53760 side_load_enemies();
19469 53760 return;
19470 }
19471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14077227 times.
14077227 if(tmpscr->pattern==pNOSPAWN) return;
19472
2/2
✓ Branch 0 taken 14042176 times.
✓ Branch 1 taken 35051 times.
14077227 if(loaded_enemies)
19473 14042176 return;
19474
19475 // check if it's the dungeon boss and it has been beaten before
19476
4/4
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 34692 times.
✓ Branch 2 taken 269 times.
✓ Branch 3 taken 90 times.
35051 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
19477 {
19478 90 loaded_enemies = true;
19479 90 return;
19480 }
19481
19482
4/4
✓ Branch 0 taken 34520 times.
✓ Branch 1 taken 441 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 34279 times.
34961 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19483 {
19484 682 side_load_enemies();
19485 682 return;
19486 }
19487
19488 34279 loaded_enemies=true;
19489
19490 // do enemies that are always loaded
19491 34279 load_default_enemies();
19492
19493 // dungeon basements
19494
19495 static byte dngn_enemy_x[4] = {32,96,144,208};
19496
19497
2/2
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 33375 times.
34279 if(currscr>=128)
19498 {
19499
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 475 times.
904 if(DMaps[currdmap].flags&dmfCAVES) return;
19500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
19501 {
19502 for(int32_t i=0; i<10; i++)
19503 {
19504 if ( tmpscr->enemy[i] )
19505 {
19506 int32_t preguycount = guys.Count();
19507 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
19508 if (guys.Count() > preguycount)
19509 {
19510 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19511 {
19512 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19513 {
19514 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19515 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19516 }
19517 }
19518 }
19519 }
19520 }
19521 }
19522 else
19523 {
19524
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19525 {
19526 1900 int32_t preguycount = guys.Count();
19527
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
19528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19529 {
19530
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19531 {
19532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19533 {
19534 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19535 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19536 4 }
19537 4 }
19538 1900 }
19539 1900 }
19540 }
19541 475 return;
19542 }
19543
19544 // check if it's been long enough to reload all enemies
19545
19546 33375 int32_t loadcnt = 10;
19547 33375 int16_t s = (currmap<<7)+currscr;
19548 33375 bool beenhere = false;
19549 33375 bool reload = true;
19550 33375 bool unbeatablereload = true;
19551
19552
2/2
✓ Branch 0 taken 200250 times.
✓ Branch 1 taken 33375 times.
233625 for(int32_t i=0; i<6; i++)
19553
2/2
✓ Branch 0 taken 191071 times.
✓ Branch 1 taken 9179 times.
209429 if(visited[i]==s)
19554 9179 beenhere = true;
19555
19556
2/2
✓ Branch 0 taken 9179 times.
✓ Branch 1 taken 24196 times.
33375 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19557 {
19558 24196 visited[vhead]=s; //If not, it adds it to the array,
19559 24196 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
19560 24196 }
19561
2/2
✓ Branch 0 taken 4611 times.
✓ Branch 1 taken 4568 times.
9179 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19562 {
19563 4568 loadcnt = 0; //It will tell it not to load any enemies,
19564 4568 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19565 4568 }
19566
19567
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 28807 times.
33375 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19568 {
19569 28807 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19570
19571
2/4
✓ Branch 0 taken 10143 times.
✓ Branch 1 taken 18664 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28807 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10143 times.
10143 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19573 18664 loadcnt = 10; //That means all enemies need to be respawned.
19574
3/4
✓ Branch 0 taken 24196 times.
✓ Branch 1 taken 4611 times.
✓ Branch 2 taken 24196 times.
✗ Branch 3 not taken.
28807 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19575 {
19576 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
19577 {
19578 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesnt_count))
19579 {
19580 unbeatablereload = false;
19581 }
19582 }
19583 if (unbeatablereload)
19584 {
19585 loadcnt = 10;
19586 }
19587 }
19588 28807 }
19589
19590
4/4
✓ Branch 0 taken 31916 times.
✓ Branch 1 taken 1459 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 31729 times.
33375 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19591 1646 loadcnt = 10; //All enemies also need to be respawned.
19592
19593 33375 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19594 33375 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in its spawn poof.
19595 33375 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19596
19597
4/4
✓ Branch 0 taken 14568 times.
✓ Branch 1 taken 99349 times.
✓ Branch 2 taken 80542 times.
✓ Branch 3 taken 33375 times.
113917 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19598 {
19599 80542 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19600 80542 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19601
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 79731 times.
80542 if (guys.Count() > preguycount)
19602 {
19603
2/2
✓ Branch 0 taken 77384 times.
✓ Branch 1 taken 2347 times.
79731 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19604 {
19605
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2343 times.
2347 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19606 {
19607 2343 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19608 2343 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19609 2343 }
19610 2347 }
19611 79731 }
19612
19613 80542 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19614 80542 }
19615
19616 33375 game->guys[s] = guycnt;
19617 //} //if(true)
19618 14130987 }
19619 233 void moneysign()
19620 {
19621 233 additem(48,108,iRupy,ipDUMMY);
19622 233 set_clip_state(pricesdisplaybuf, 0);
19623 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19624 233 }
19625
19626 3252 void putprices(bool sign)
19627 {
19628
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 3223 times.
3252 if(fadeclk > 0) return;
19629
19630 3223 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19631 3223 int32_t step=32;
19632 3223 int32_t x=80;
19633
19634
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2942 times.
3223 if(prices[2]==0)
19635 {
19636 2942 step<<=1;
19637
19638
2/2
✓ Branch 0 taken 2910 times.
✓ Branch 1 taken 32 times.
2942 if(prices[1]==0)
19639 {
19640 2910 x=112;
19641 2910 }
19642 2942 }
19643
19644
2/2
✓ Branch 0 taken 3223 times.
✓ Branch 1 taken 9669 times.
12892 for(int32_t i=0; i<3; i++)
19645 {
19646 // Kind of stupid, but it works: 100000 is used to indicate that an item
19647 // has a price of zero rather than there being no item.
19648 // 100000 isn't a valid price, so this doesn't cause problems.
19649
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8630 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9669 if(prices[i]!=0 && prices[i]<100000)
19650 {
19651 char buf[8];
19652 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19653
19654 1039 int32_t l=(int32_t)strlen(buf);
19655 1039 set_clip_state(pricesdisplaybuf, 0);
19656
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19657 1039 }
19658
19659 9669 x+=step;
19660 9669 }
19661 3252 }
19662
19663 // Setting up special rooms
19664 // Also called when the Letter is used successfully.
19665 1202 void setupscreen()
19666 {
19667 1202 boughtsomething=false;
19668 1202 int32_t t=currscr<128?0:1;
19669 1202 word str=tmpscr[t].str;
19670
19671 // Prices are already set to 0 in dowarp()
19672
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1202 switch(tmpscr[t].room)
19673 {
19674 case rSP_ITEM: // special item
19675 161 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19676 161 break;
19677
19678 case rINFO: // pay for info
19679 {
19680 28 int32_t count = 0;
19681 28 int32_t base = 88;
19682 28 int32_t step = 5;
19683
19684 28 moneysign();
19685
19686
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19687 {
19688
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[tmpscr[t].catchall].str[i])
19689 {
19690 84 ++count;
19691 84 }
19692 else
19693 break;
19694 84 }
19695
19696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19697 {
19698
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19699 {
19700 base = 88+32;
19701 }
19702
19703
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19704 {
19705 step = 6;
19706 }
19707
19708
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19709 {
19710 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19711 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19712 84 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
19713
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19714 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19715 84 int32_t itemid = current_item_id(itype_wealthmedal);
19716
19717
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19718 {
19719 if(itemsbuf[itemid].flags & item_flag1)
19720 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19721 else
19722 prices[i]-=itemsbuf[itemid].misc1;
19723 prices[i]=vbound(prices[i], -99999, 0);
19724 if(prices[i]==0)
19725 prices[i]=100000;
19726 }
19727
19728
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19729 prices[i]=-1;
19730 84 }
19731 28 }
19732
19733 28 break;
19734 }
19735
19736 case rMONEY: // secret money
19737 44 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19738 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19739 44 break;
19740
19741 case rGAMBLE: // gambling
19742 11 prices[0]=prices[1]=prices[2]=-10;
19743 11 moneysign();
19744 11 additem(88,89,iRupy,ipMONEY+ipDUMMY);
19745 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19746 11 additem(120,89,iRupy,ipMONEY+ipDUMMY);
19747 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19748 11 additem(152,89,iRupy,ipMONEY+ipDUMMY);
19749 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19750 11 break;
19751
19752 case rREPAIR: // door repair
19753
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19754 // }
19755 13 repaircharge=tmpscr[t].catchall;
19756 13 break;
19757
19758 case rMUPGRADE: // upgrade magic
19759 2 adjustmagic=true;
19760 2 break;
19761
19762 case rLEARNSLASH: // learn slash attack
19763 2 learnslash=true;
19764 2 break;
19765
19766 case rRP_HC: // heart container or red potion
19767 17 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19768 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19769 17 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19770 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19771 17 break;
19772
19773 case rP_SHOP: // potion shop
19774
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19775 {
19776 12 str=0;
19777 12 break;
19778 }
19779
19780 [[fallthrough]];
19781 case rTAKEONE: // take one
19782 case rSHOP: // shop
19783 {
19784 194 int32_t count = 0;
19785 194 int32_t base = 88;
19786 194 int32_t step = 5;
19787
19788
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(tmpscr[t].room != rTAKEONE)
19789 193 moneysign();
19790
19791 //count and align the stuff
19792
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19793 {
19794
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
19795 {
19796 523 ++count;
19797 523 }
19798 else
19799 {
19800 37 break;
19801 }
19802 523 }
19803
19804
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19805 {
19806 22 base = 88+32;
19807 22 }
19808
19809
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19810 {
19811 15 step = 6;
19812 15 }
19813
19814
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19815 {
19816 523 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
19817 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19818
19819
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(tmpscr[t].room != rTAKEONE)
19820 {
19821 521 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
19822
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19823 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19824 521 int32_t itemid = current_item_id(itype_wealthmedal);
19825
19826
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19827 {
19828
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19829 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19830 else
19831 prices[i]+=itemsbuf[itemid].misc1;
19832 9 prices[i]=vbound(prices[i], 0, 99999);
19833
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19834 prices[i]=100000;
19835 9 }
19836
19837
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
19838 prices[i]=1;
19839 521 }
19840 523 }
19841
19842 194 break;
19843 }
19844 case rBOTTLESHOP: // bottle shop
19845 {
19846 1 int32_t count = 0;
19847 1 int32_t base = 88;
19848 1 int32_t step = 5;
19849
19850 1 moneysign();
19851 1 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
19852 //count and align the stuff
19853
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19854 {
19855
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19856 {
19857 3 ++count;
19858 3 }
19859 else
19860 {
19861 break;
19862 }
19863 3 }
19864
19865
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19866 {
19867 base = 88+32;
19868 }
19869
19870
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19871 {
19872 step = 6;
19873 }
19874
19875
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19876 {
19877 3 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19878 //{ Setup dummy item
19879 3 item* curItem = ((item*)items.spr(items.Count()-1));
19880 3 curItem->PriceIndex = i;
19881 3 newcombo const& cmb = combobuf[bst.comb[i]];
19882 3 curItem->o_tile = cmb.o_tile;
19883 3 curItem->o_cset = bst.cset[i];
19884 3 curItem->cs = curItem->o_cset;
19885 3 curItem->tile = cmb.o_tile;
19886 3 curItem->o_speed = cmb.speed;
19887 3 curItem->o_delay = 0;
19888 3 curItem->frames = cmb.frames;
19889 3 curItem->flip = cmb.flip;
19890 3 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
19891 3 curItem->pstring = 0;
19892 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19893 3 curItem->flash = false;
19894 3 curItem->twohand = false;
19895 3 curItem->anim = true;
19896 3 curItem->hit_width=1;
19897 3 curItem->hyofs=4;
19898 3 curItem->hit_height=12;
19899 3 curItem->script=0;
19900 3 curItem->txsz=1;
19901 3 curItem->tysz=1;
19902 //}
19903
19904 3 prices[i] = bst.price[i];
19905
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19906 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19907 3 int32_t itemid = current_item_id(itype_wealthmedal);
19908
19909
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19910 {
19911 if(itemsbuf[itemid].flags & item_flag1)
19912 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19913 else
19914 prices[i]+=itemsbuf[itemid].misc1;
19915 prices[i]=vbound(prices[i], 0, 99999);
19916 if(prices[i]==0)
19917 prices[i]=100000;
19918 }
19919
19920
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19921 prices[i]=1;
19922 3 }
19923
19924 1 break;
19925 }
19926
19927 case rBOMBS: // more bombs
19928 19 additem(120,89,iRupy,ipDUMMY+ipMONEY);
19929 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19930 19 prices[0]=-tmpscr[t].catchall;
19931 19 break;
19932
19933 case rARROWS: // more arrows
19934 additem(120,89,iRupy,ipDUMMY+ipMONEY);
19935 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19936 prices[0]=-tmpscr[t].catchall;
19937 break;
19938
19939 case rSWINDLE: // leave heart container or money
19940 14 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
19941 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19942 14 prices[0]=-1;
19943 14 additem(152,89,iRupy,ipDUMMY+ipMONEY);
19944 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19945 14 prices[1]=-tmpscr[t].catchall;
19946 14 break;
19947
19948 }
19949
19950
3/4
✓ Branch 0 taken 1183 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1183 times.
1202 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
19951 {
19952 19 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
19953 19 int32_t itemid = current_item_id(itype_wealthmedal);
19954
19955
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19956 {
19957 if(itemsbuf[itemid].flags & item_flag1)
19958 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19959 else
19960 prices[i]+=itemsbuf[itemid].misc1;
19961 }
19962
19963
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(tmpscr[t].catchall>1 && prices[i]>-1)
19964 prices[i]=-1;
19965 19 }
19966
19967 1202 putprices(false);
19968
19969
2/2
✓ Branch 0 taken 1142 times.
✓ Branch 1 taken 60 times.
1202 if(str)
19970 {
19971 1142 donewmsg(str);
19972 1142 }
19973 else
19974 {
19975 60 Hero.unfreeze();
19976 }
19977 1202 }
19978
19979 // Increments msgptr and returns the control code argument pointed at.
19980 3409 word grab_next_argument()
19981 {
19982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3409 times.
3409 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
19983 3409 byte val=MsgStrings[msgstr].s[++msgptr]-1;
19984 3409 word ret=val;
19985
19986 // If an argument is succeeded by 255, then it's a three-byte argument -
19987 // between 254 and 65535 (or whatever the maximum actually is)
19988
2/2
✓ Branch 0 taken 3285 times.
✓ Branch 1 taken 109 times.
3409 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
19989
2/2
✓ Branch 0 taken 3394 times.
✓ Branch 1 taken 15 times.
3409 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
19990 {
19991 109 val=MsgStrings[msgstr].s[msgptr+2];
19992 109 word next=val;
19993 109 ret += 254*next;
19994 109 msgptr+=2;
19995 109 }
19996
19997 3409 return ret;
19998 3409 }
19999
20000 enum
20001 {
20002 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
20003 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
20004
20005 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
20006
20007 MNU_DATA_MAX
20008 };
20009 struct menu_choice
20010 {
20011 int32_t x, y;
20012 int32_t pos;
20013 int32_t upos, dpos, lpos, rpos;
20014 8 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
20015 8 {}
20016 8 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
20017 int32_t dpos, int32_t lpos, int32_t rpos)
20018 8 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
20019 8 {}
20020 };
20021 static int32_t msg_menu_data[MNU_DATA_MAX];
20022 static bool do_run_menu = false;
20023 bool do_end_str = false;
20024 static bool wait_advance = false;
20025 356 static std::map<int32_t, menu_choice> menu_options;
20026 43107 void clr_msg_data()
20027 {
20028 43107 do_end_str = false;
20029 43107 wait_advance = false;
20030 43107 do_run_menu = false;
20031 43107 menu_options.clear();
20032 43107 memset(msg_menu_data, 0, sizeof(msg_menu_data));
20033 43107 }
20034
20035 static bool doing_name_insert = false;
20036 static char namebuf[9] = {0};
20037 static char* nameptr = NULL;
20038 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
20039 965 bool runMenuCursor()
20040 {
20041 965 clear_bitmap(msg_menu_bmp_buf);
20042
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!menu_options.size())
20043 {
20044 msg_menu_data[MNU_CHOSEN] = 0;
20045 return true; //end menu
20046 }
20047 965 int32_t pos = msg_menu_data[MNU_CHOSEN];
20048 //If the cursor is at an invalid pos, find the first pos >= 0...
20049
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(menu_options.find(pos) == menu_options.end())
20050 {
20051 pos = 0;
20052 while(menu_options.find(pos) == menu_options.end())
20053 ++pos;
20054 }
20055 965 menu_choice* ch = &menu_options[pos];
20056
20057 965 bool pressed = true;
20058
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 964 times.
965 if(rUp()) pos = ch->upos;
20059
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 962 times.
964 else if(rDown()) pos = ch->dpos;
20060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 else if(rLeft()) pos = ch->lpos;
20061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962 times.
962 else if(rRight()) pos = ch->rpos;
20062 962 else pressed = false;
20063
20064
2/2
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
965 if(pressed)
20065 3 msg_menu_data[MNU_TIMER] = 1;
20066
20067 965 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
20068 965 bool held = false;
20069
2/2
✓ Branch 0 taken 917 times.
✓ Branch 1 taken 48 times.
965 if(hold_input)
20070 {
20071 48 held = true;
20072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(Up()) pos = ch->upos;
20073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Down()) pos = ch->dpos;
20074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Left()) pos = ch->lpos;
20075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 else if(Right()) pos = ch->rpos;
20076 48 else held = false;
20077 48 }
20078 //If the cursor is at an invalid pos, find the first pos >= 0...
20079
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(menu_options.find(pos) == menu_options.end())
20080 {
20081 pos = 0;
20082 while(menu_options.find(pos) == menu_options.end())
20083 ++pos;
20084 }
20085
4/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 3 times.
965 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
20086 3 sfx(MsgStrings[msgstr].sfx);
20087
20088 965 ch = &menu_options[pos];
20089 1930 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
20090 965 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
20091 965 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
20092 965 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
20093
20094 965 msg_menu_data[MNU_CHOSEN] = pos;
20095
20096
2/2
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 24 times.
965 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
20097 {
20098 24 rAbtn(); //Eat
20099
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2 times.
24 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
20100 24 }
20101
20102
3/4
✓ Branch 0 taken 962 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 962 times.
965 bool ret = (pressed || held) ? false : rAbtn();
20103 //Eat inputs
20104 965 rUp(); rDown(); rLeft(); rRight(); rAbtn();
20105
20106
2/2
✓ Branch 0 taken 963 times.
✓ Branch 1 taken 2 times.
965 if(ret)
20107 2 menu_options.clear();
20108
20109 965 return ret;
20110 //false if pos changed this frame; no confirming while moving the cursor!
20111 965 }
20112
20113 673819 bool bottom_margin_clip()
20114 {
20115 709016 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
20116
2/2
✓ Branch 0 taken 638622 times.
✓ Branch 1 taken 35197 times.
673819 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
20117 }
20118
20119 void update_msgstr();
20120 242981 bool parsemsgcode()
20121 {
20122
2/2
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 240294 times.
242981 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
20123 240294 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
20124
18/39
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 237259 times.
✓ Branch 2 taken 1276 times.
✓ Branch 3 taken 1463 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 68 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 9 times.
✓ Branch 14 taken 17 times.
✓ Branch 15 taken 7 times.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 122 times.
✓ Branch 25 taken 13 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 2 times.
✓ Branch 30 taken 8 times.
✓ Branch 31 taken 2 times.
✓ Branch 32 taken 4 times.
✓ Branch 33 taken 1 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
240294 switch(c)
20125 {
20126 case MSGC_NEWLINE:
20127 {
20128 1276 ssc_tile_hei = ssc_tile_hei_buf;
20129
1/2
✓ Branch 0 taken 1276 times.
✗ Branch 1 not taken.
1276 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20130 1276 ssc_tile_hei_buf = -1;
20131 1276 cursor_y += thei + MsgStrings[msgstr].vspace;
20132 1276 cursor_x=msg_margins[left];
20133 1276 return true;
20134 }
20135
20136 case MSGC_COLOUR:
20137 {
20138 1463 int32_t cset = (grab_next_argument());
20139 1463 msgcolour = CSET(cset)+(grab_next_argument());
20140 1463 return true;
20141 }
20142
20143 case MSGC_SHDCOLOR:
20144 {
20145 int32_t cset = (grab_next_argument());
20146 msg_shdcol = CSET(cset)+(grab_next_argument());
20147 return true;
20148 }
20149 case MSGC_SHDTYPE:
20150 {
20151 msg_shdtype = grab_next_argument();
20152 return true;
20153 }
20154
20155 case MSGC_SPEED:
20156 {
20157 33 msgspeed=grab_next_argument();
20158 33 return true;
20159 }
20160
20161 case MSGC_CTRUP:
20162 {
20163 int32_t a1 = grab_next_argument();
20164 int32_t a2 = grab_next_argument();
20165 game->change_counter(a2, a1);
20166 return true;
20167 }
20168
20169 case MSGC_CTRDN:
20170 {
20171 2 int32_t a1 = grab_next_argument();
20172 2 int32_t a2 = grab_next_argument();
20173 2 game->change_counter(-a2, a1);
20174 2 return true;
20175 }
20176
20177 case MSGC_CTRSET:
20178 {
20179 int32_t a1 = grab_next_argument();
20180 int32_t a2 = grab_next_argument();
20181 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20182 return true;
20183 }
20184
20185 case MSGC_CTRUPPC:
20186 case MSGC_CTRDNPC:
20187 case MSGC_CTRSETPC:
20188 {
20189 2 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
20190 2 int32_t counter = grab_next_argument();
20191 2 int32_t amount = grab_next_argument();
20192 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20193
20194
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(code==MSGC_CTRDNPC)
20195 amount*=-1;
20196
20197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(code==MSGC_CTRSETPC)
20198 game->set_counter(amount, counter);
20199 else
20200 2 game->change_counter(amount, counter);
20201
20202 2 return true;
20203 }
20204
20205 case MSGC_GIVEITEM:
20206 {
20207 68 int32_t itemID = grab_next_argument();
20208
20209 68 getitem(itemID, true);
20210
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
68 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20211 {
20212 68 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20213 68 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20214 68 }
20215 68 return true;
20216 }
20217
20218
20219 case MSGC_WARP:
20220 {
20221 int32_t dmap = grab_next_argument();
20222 int32_t scrn = grab_next_argument();
20223 int32_t dx = grab_next_argument();
20224 int32_t dy = grab_next_argument();
20225 int32_t wfx = grab_next_argument();
20226 int32_t sfx = grab_next_argument();
20227 if(dx >= MAX_SCC_ARG) dx = -1;
20228 if(dy >= MAX_SCC_ARG) dy = -1;
20229 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20230 do_end_str = true;
20231 return true;
20232 }
20233
20234 case MSGC_SETSCREEND:
20235 {
20236 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20237 int32_t screen = grab_next_argument();
20238 int32_t reg = grab_next_argument();
20239 int32_t val = grab_next_argument();
20240 FFCore.set_screen_d(screen + dmap, reg, val);
20241 return true;
20242 }
20243 case MSGC_TAKEITEM:
20244 {
20245 9 int32_t itemID = grab_next_argument();
20246
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( FFCore.doscript(ScriptType::Item, itemID) )
20247 {
20248 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20249 }
20250 9 takeitem(itemID);
20251
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_bwpn == itemID )
20252 {
20253 game->forced_bwpn = -1;
20254 } //not else if! -Z
20255
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_awpn == itemID )
20256 {
20257 game->forced_awpn = -1;
20258 }
20259
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_xwpn == itemID )
20260 {
20261 game->forced_xwpn = -1;
20262 } //not else if! -Z
20263
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( game->forced_ywpn == itemID )
20264 {
20265 game->forced_ywpn = -1;
20266 }
20267 9 verifyBothWeapons();
20268 9 return true;
20269 }
20270
20271 case MSGC_SFX:
20272 {
20273 17 sfx((int32_t)grab_next_argument(),128);
20274 17 return true;
20275 }
20276
20277 case MSGC_MIDI:
20278 {
20279 7 int32_t music = (int32_t)(grab_next_argument());
20280
20281
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20282 1 music_stop();
20283 else
20284 6 jukebox(music+(ZC_MIDI_COUNT-1));
20285
20286 7 return true;
20287 }
20288
20289 case MSGC_NAME:
20290 {
20291 6 doing_name_insert = true;
20292 6 sprintf(namebuf, "%s", game->get_name());
20293 6 nameptr = namebuf;
20294 6 return true;
20295 }
20296
20297 case MSGC_FONT:
20298 {
20299 int fontid = grab_next_argument();
20300 int oh = text_height(msgfont);
20301 msgfont = get_zc_font(fontid);
20302 int nh = text_height(msgfont);
20303 int mh = std::max(oh,nh);
20304 if(mh > ssc_tile_hei_buf)
20305 ssc_tile_hei_buf = mh;
20306 return true;
20307 }
20308 case MSGC_RUN_FRZ_GENSCR:
20309 {
20310 word scr_id = grab_next_argument();
20311 bool force_redraw = grab_next_argument()!=0;
20312 if(force_redraw)
20313 {
20314 update_msgstr();
20315 draw_screen(tmpscr);
20316 }
20317 FFCore.runGenericFrozenEngine(scr_id);
20318 return true;
20319 }
20320 case MSGC_DRAWTILE:
20321 {
20322 int32_t tl = grab_next_argument();
20323 int32_t cs = grab_next_argument();
20324 int32_t t_wid = grab_next_argument();
20325 int32_t t_hei = grab_next_argument();
20326 int32_t fl = grab_next_argument();
20327
20328 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20329 {
20330 ssc_tile_hei = ssc_tile_hei_buf;
20331 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20332 ssc_tile_hei_buf = -1;
20333 cursor_y += thei + MsgStrings[msgstr].vspace;
20334 if(bottom_margin_clip()) return true;
20335 cursor_x=msg_margins[left];
20336 }
20337
20338 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20339 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20340 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20341 return true;
20342 }
20343
20344 case MSGC_GOTOIFRAND:
20345 {
20346 int32_t odds = (int32_t)(grab_next_argument());
20347
20348 if(!odds || !(zc_oldrand()%odds))
20349 goto switched;
20350
20351 (void)grab_next_argument();
20352 return true;
20353 }
20354
20355 case MSGC_GOTOIFGLOBAL:
20356 {
20357 int32_t arg = (int32_t)grab_next_argument();
20358 int32_t d = zc_min(7,arg);
20359 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20360 arg = (int32_t)grab_next_argument();
20361
20362 if(game->screen_d[s][d] >= arg)
20363 goto switched;
20364
20365 (void)grab_next_argument();
20366 return true;
20367 }
20368
20369 case MSGC_CHANGEPORTRAIT:
20370 {
20371 return true; //not implemented
20372 }
20373
20374 case MSGC_GOTOIFCREEND:
20375 {
20376 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20377 int32_t screen = grab_next_argument();
20378 int32_t reg = grab_next_argument();
20379 int32_t val = grab_next_argument();
20380 //int32_t nxtstr = grab_next_argument();
20381 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20382 {
20383 goto switched;
20384 }
20385 (void)grab_next_argument();
20386 return true;
20387 }
20388
20389 case MSGC_GOTOIF:
20390 {
20391 122 int32_t it = (int32_t)grab_next_argument();
20392
20393
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20394 35 goto switched;
20395
20396 87 (void)grab_next_argument();
20397 87 return true;
20398 }
20399
20400 case MSGC_GOTOIFCTR:
20401 {
20402
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6 times.
13 if(game->get_counter(grab_next_argument())>=grab_next_argument())
20403 7 goto switched;
20404
20405 6 (void)grab_next_argument();
20406 6 return true;
20407 }
20408
20409 case MSGC_GOTOIFCTRPC:
20410 {
20411 int32_t counter = grab_next_argument();
20412 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
20413
20414 if(game->get_counter(counter)>=amount)
20415 goto switched;
20416
20417 (void)grab_next_argument();
20418 return true;
20419 }
20420
20421 case MSGC_GOTOIFTRICOUNT:
20422 {
20423 if(TriforceCount() >= (int32_t)(grab_next_argument()))
20424 goto switched;
20425
20426 (void)grab_next_argument();
20427 return true;
20428 }
20429
20430 case MSGC_GOTOIFTRI:
20431 {
20432 int32_t lev = (int32_t)(grab_next_argument());
20433
20434 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20435 goto switched;
20436
20437 (void)grab_next_argument();
20438 return true;
20439 }
20440
20441 case MSGC_SETUPMENU:
20442 {
20443 2 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
20444 2 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
20445 2 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
20446 2 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
20447 2 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
20448 2 return true;
20449 }
20450
20451 case MSGC_MENUCHOICE:
20452 {
20453 8 int32_t pos = grab_next_argument();
20454 8 int32_t upos = grab_next_argument();
20455 8 int32_t dpos = grab_next_argument();
20456 8 int32_t lpos = grab_next_argument();
20457 8 int32_t rpos = grab_next_argument();
20458
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20459 {
20460 2 ssc_tile_hei = ssc_tile_hei_buf;
20461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20462 2 ssc_tile_hei_buf = -1;
20463 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20465 2 cursor_x=msg_margins[left];
20466 2 }
20467
20468 16 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20469 8 upos, dpos, lpos, rpos);
20470
20471
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20472 8 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20473 8 return true;
20474 }
20475
20476 case MSGC_RUNMENU:
20477 {
20478 2 msg_menu_data[MNU_CHOSEN] = 0;
20479 2 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(menu_options.size() < 1)
20481 return true;
20482 2 do_run_menu = true;
20483 2 return true;
20484 }
20485
20486 case MSGC_GOTOMENUCHOICE:
20487 {
20488 4 int32_t choice = grab_next_argument();
20489
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(msg_menu_data[MNU_CHOSEN] == choice)
20490 2 goto switched;
20491 2 (void)grab_next_argument();
20492 2 return true;
20493 }
20494
20495 case MSGC_ENDSTRING:
20496 {
20497 1 do_end_str = true;
20498 1 return true;
20499 }
20500 case MSGC_WAIT_ADVANCE:
20501 {
20502 wait_advance = true;
20503 linkedmsgclk = 51;
20504 return true;
20505 }
20506 case MSGC_TRIGSECRETS:
20507 {
20508 bool perm = (bool)grab_next_argument();
20509 hidden_entrance(0, true, false, -8);
20510 if(perm)
20511 setmapflag(mSECRET);
20512 return true;
20513 }
20514 case MSGC_TRIG_CMB_COPYCAT:
20515 {
20516 int copy_id = (int)grab_next_argument();
20517 if(copy_id == byte(copy_id))
20518 trig_copycat(copy_id);
20519 return true;
20520 }
20521 case MSGC_SETSCREENSTATE:
20522 {
20523 int32_t flag = int32_t(grab_next_argument());
20524 if(unsigned(flag)>=mMAXIND)
20525 {
20526 Z_error("SCC 133: Flag %d is invalid\n", flag);
20527 return true;
20528 }
20529 bool state = bool(grab_next_argument());
20530 if(state)
20531 setmapflag(1<<flag);
20532 else
20533 unsetmapflag(1<<flag,true);
20534 return true;
20535 }
20536 case MSGC_SETSCREENSTATER:
20537 {
20538 int32_t map = (int32_t)grab_next_argument();
20539 int32_t scrid = (int32_t)grab_next_argument();
20540 if(map < 1 || map > map_count)
20541 {
20542 Z_error("SCC 134: Map %d is invalid\n", map);
20543 return true;
20544 }
20545 if(unsigned(scrid)>=0x80)
20546 {
20547 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20548 return true;
20549 }
20550
20551 int32_t flag = int32_t(grab_next_argument());
20552 if(unsigned(flag)>=mMAXIND)
20553 {
20554 Z_error("SCC 134: Flag %d is invalid\n", flag);
20555 return true;
20556 }
20557 bool state = bool(grab_next_argument());
20558 if(state)
20559 setmapflag(mapind(map,scrid),1<<flag);
20560 else
20561 unsetmapflag(mapind(map,scrid),1<<flag,true);
20562 return true;
20563 }
20564 switched:
20565 44 int32_t lev = (int32_t)(grab_next_argument());
20566
2/4
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
44 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20567
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 31 times.
44 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20568 {
20569 msgstr=lev;
20570 msgpos=msgptr=0;
20571 msgfont=setmsgfont();
20572 }
20573 else
20574 {
20575 44 donewmsg(lev);
20576 44 ssc_tile_hei_buf = -1;
20577 }
20578 44 msgptr--; // To counteract it being incremented after this routine is called.
20579 44 putprices(false);
20580 44 return true;
20581 }
20582
20583 237259 return false;
20584 242981 }
20585
20586 // Wraps the message string... probably.
20587 233741 void wrapmsgstr(char *s3)
20588 {
20589 233741 int32_t j=0;
20590
20591
2/2
✓ Branch 0 taken 23941 times.
✓ Branch 1 taken 209800 times.
233741 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
20592 {
20593
2/2
✓ Branch 0 taken 4767 times.
✓ Branch 1 taken 19174 times.
23941 if(msgspace)
20594 {
20595 4767 char c = MsgStrings[msgstr].s[msgptr];
20596
4/6
✓ Branch 0 taken 4440 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4440 times.
✗ Branch 5 not taken.
4767 if(c != ' ' && c >= 32 && c <= 126)
20597 {
20598
4/4
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 24450 times.
✓ Branch 2 taken 20132 times.
✓ Branch 3 taken 4440 times.
24572 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
20599 {
20600
3/4
✓ Branch 0 taken 19569 times.
✓ Branch 1 taken 563 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19569 times.
20132 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
20601 20132 }
20602
20603 4440 s3[j] = 0;
20604 4440 msgspace = false;
20605 4440 }
20606 else
20607 {
20608 327 s3[0] = c;
20609 327 s3[1] = 0;
20610 }
20611 4767 }
20612 else
20613 {
20614 19174 s3[0] = MsgStrings[msgstr].s[msgptr];
20615 19174 s3[1] = 0;
20616
20617
2/2
✓ Branch 0 taken 15129 times.
✓ Branch 1 taken 4045 times.
19174 if(s3[0] == ' ') msgspace=true;
20618 }
20619 23941 }
20620 else
20621 {
20622 209800 s3[0] = MsgStrings[msgstr].s[msgptr];
20623 209800 s3[1] = 0;
20624 }
20625 233741 }
20626
20627 // Returns true if the pointer is at a string's
20628 // null terminator or a trailing space
20629 805686 bool atend(char const* str)
20630 {
20631 805686 int32_t i=0;
20632
20633
2/2
✓ Branch 0 taken 6343123 times.
✓ Branch 1 taken 805686 times.
7148809 while(str[i]==' ')
20634 6343123 i++;
20635
20636 805686 return str[i]=='\0';
20637 }
20638
20639 14467299 void putmsg()
20640 {
20641 14467299 bool oldmargin = get_qr(qr_OLD_STRING_EDITOR_MARGINS)!=0;
20642
2/2
✓ Branch 0 taken 668908 times.
✓ Branch 1 taken 13798391 times.
14467299 if(!msgorig) msgorig=msgstr;
20643
20644
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14467299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14467299 if(wait_advance && linkedmsgclk < 1)
20645 linkedmsgclk = 1;
20646
2/2
✓ Branch 0 taken 14194616 times.
✓ Branch 1 taken 272683 times.
14467299 if(linkedmsgclk>0)
20647 {
20648
2/2
✓ Branch 0 taken 126232 times.
✓ Branch 1 taken 146451 times.
272683 if(linkedmsgclk==1)
20649 {
20650
6/6
✓ Branch 0 taken 126231 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 123411 times.
✓ Branch 3 taken 2820 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 123303 times.
126232 if(do_end_str||cAbtn()||cBbtn())
20651 {
20652 2929 do_end_str = false;
20653 2929 linkedmsgclk = 0;
20654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2929 times.
2929 if(wait_advance)
20655 {
20656 wait_advance = false;
20657 }
20658 else
20659 {
20660 2929 msgstr=MsgStrings[msgstr].nextstring;
20661 2929 ssc_tile_hei_buf = -1;
20662
3/4
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 1986 times.
✓ Branch 2 taken 943 times.
✗ Branch 3 not taken.
2929 if(!msgstr && enqueued_str)
20663 {
20664 msgstr = enqueued_str;
20665 enqueued_str = 0;
20666 }
20667
2/2
✓ Branch 0 taken 1986 times.
✓ Branch 1 taken 943 times.
2929 if(!msgstr)
20668 {
20669 943 msgfont=get_zc_font(font_zfont);
20670
20671
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 939 times.
943 if(tmpscr->room!=rGRUMBLE)
20672 939 blockpath=false;
20673
20674 943 dismissmsg();
20675 943 goto disappear;
20676 }
20677
20678 1986 donewmsg(msgstr);
20679 1986 putprices(false);
20680 }
20681 1986 }
20682 125289 }
20683 else
20684 {
20685 146451 --linkedmsgclk;
20686 }
20687 271740 }
20688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14466356 times.
14466356 if(wait_advance) return; //Waiting for buttonpress
20689
20690
10/10
✓ Branch 0 taken 14464043 times.
✓ Branch 1 taken 2313 times.
✓ Branch 2 taken 663737 times.
✓ Branch 3 taken 13800306 times.
✓ Branch 4 taken 527084 times.
✓ Branch 5 taken 136653 times.
✓ Branch 6 taken 263640 times.
✓ Branch 7 taken 263444 times.
✓ Branch 8 taken 854 times.
✓ Branch 9 taken 262786 times.
14466356 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
20691 {
20692
2/2
✓ Branch 0 taken 400951 times.
✓ Branch 1 taken 13800306 times.
14201257 if(!msgstr)
20693 13800306 msgorig=0;
20694
20695 14201257 msg_active = false;
20696 14201257 return;
20697 }
20698
20699 265099 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20700
20701 char s3[145];
20702 int32_t tlength;
20703
20704 // Bypass the string with the B button!
20705
4/4
✓ Branch 0 taken 1343 times.
✓ Branch 1 taken 263756 times.
✓ Branch 2 taken 1240 times.
✓ Branch 3 taken 262516 times.
265099 if(((cBbtn())&&(get_qr(qr_ALLOWMSGBYPASS))) || msgspeed==0)
20706 {
20707 //finish writing out the string
20708
4/4
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 79061 times.
✓ Branch 2 taken 1232 times.
✓ Branch 3 taken 77932 times.
80514 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
20709 {
20710
5/6
✓ Branch 0 taken 18708 times.
✓ Branch 1 taken 59224 times.
✓ Branch 2 taken 18707 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 18707 times.
✗ Branch 5 not taken.
77932 if(msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20711 1 goto breakout; // break out if message speed was changed to non-zero
20712
4/6
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77931 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 285 times.
✓ Branch 5 taken 77646 times.
77931 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
20713 {
20714
1/2
✓ Branch 0 taken 77646 times.
✗ Branch 1 not taken.
77646 if(bottom_margin_clip())
20715 break;
20716
20717 77646 wrapmsgstr(s3);
20718
20719
2/2
✓ Branch 0 taken 20449 times.
✓ Branch 1 taken 57197 times.
77646 if(MsgStrings[msgstr].s[msgptr]==' ')
20720 {
20721 20449 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
20722
20723
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 1347 times.
21843 if(cursor_x+tlength > (msg_w-msg_margins[right])
20724
5/6
✓ Branch 0 taken 1394 times.
✓ Branch 1 taken 19055 times.
✓ Branch 2 taken 1394 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1300 times.
✓ Branch 5 taken 47 times.
20449 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20725 47 ? true : strcmp(s3," ")!=0))
20726 {
20727 1347 ssc_tile_hei = ssc_tile_hei_buf;
20728
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20729 1347 ssc_tile_hei_buf = -1;
20730 1347 cursor_y += thei + MsgStrings[msgstr].vspace;
20731
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 if(bottom_margin_clip()) break;
20732 1347 cursor_x=msg_margins[left];
20733 1347 }
20734
20735 20449 char buf[2] = {0};
20736 20449 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
20737
20738 20449 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20739
20740 20449 cursor_x+=tlength;
20741 20449 }
20742 else
20743 {
20744 57197 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20745
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 536 times.
57923 if(cursor_x+tlength > (msg_w-msg_margins[right])
20746
5/6
✓ Branch 0 taken 773 times.
✓ Branch 1 taken 56424 times.
✓ Branch 2 taken 726 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 583 times.
✗ Branch 5 not taken.
57197 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20747 190 ? true : strcmp(s3," ")!=0))
20748 {
20749 773 ssc_tile_hei = ssc_tile_hei_buf;
20750
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20751 773 ssc_tile_hei_buf = -1;
20752 773 cursor_y += thei + MsgStrings[msgstr].vspace;
20753
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(bottom_margin_clip()) break;
20754 773 cursor_x=msg_margins[left];
20755 773 }
20756
20757 57197 sfx(MsgStrings[msgstr].sfx);
20758
20759 57197 char buf[2] = {0};
20760 57197 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
20761
20762 57197 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20763
20764 57197 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
20765 57197 cursor_x += MsgStrings[msgstr].hspace;
20766 }
20767
20768 77646 msgpos++;
20769 77646 }
20770
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(do_run_menu)
20771 {
20772 if(runMenuCursor())
20773 {
20774 do_run_menu = false;
20775 }
20776 else break;
20777 }
20778
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(doing_name_insert)
20779 {
20780 if(*nameptr)
20781 {
20782 if(bottom_margin_clip())
20783 break;
20784
20785 char s3[9] = {0};
20786
20787 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
20788 {
20789 strcpy(s3, nameptr);
20790 }
20791 else
20792 {
20793 s3[0] = *nameptr;
20794 s3[1] = 0;
20795 }
20796
20797 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20798
20799 if(cursor_x+tlength > (msg_w-msg_margins[right])
20800 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20801 ? true : strcmp(s3," ")!=0))
20802 {
20803 ssc_tile_hei = ssc_tile_hei_buf;
20804 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20805 ssc_tile_hei_buf = -1;
20806 cursor_y += thei + MsgStrings[msgstr].vspace;
20807 if(bottom_margin_clip()) break;
20808 cursor_x=msg_margins[left];
20809 }
20810
20811 sfx(MsgStrings[msgstr].sfx);
20812
20813 char buf[2] = {0};
20814 sprintf(buf,"%c",*nameptr);
20815
20816 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20817
20818 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
20819 cursor_x += MsgStrings[msgstr].hspace;
20820 ++nameptr;
20821 continue; //don't advance the msgptr, as the next char in it was not processed!
20822 }
20823 else doing_name_insert = false;
20824 }
20825 77931 ++msgptr;
20826
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(do_end_str)
20827 goto strendcheck;
20828
1/2
✓ Branch 0 taken 77931 times.
✗ Branch 1 not taken.
77931 if(wait_advance)
20829 return;
20830
2/2
✓ Branch 0 taken 76718 times.
✓ Branch 1 taken 1213 times.
77931 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
20831 {
20832
2/2
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 786 times.
1213 if(MsgStrings[msgstr].nextstring)
20833 {
20834
1/2
✓ Branch 0 taken 786 times.
✗ Branch 1 not taken.
786 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20835 {
20836 msgstr=MsgStrings[msgstr].nextstring;
20837 msgpos=msgptr=0;
20838 msgfont=setmsgfont();
20839 }
20840 786 }
20841 1213 }
20842 }
20843
20844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1232 times.
1232 if (!do_run_menu)
20845 {
20846 1232 msgclk = 72;
20847 1232 msgpos = 10000;
20848 1232 }
20849 1232 }
20850 else
20851 262516 {
20852 breakout:
20853 262517 word tempspeed = msgspeed;
20854
2/2
✓ Branch 0 taken 261554 times.
✓ Branch 1 taken 963 times.
262517 if (do_run_menu)
20855 963 tempspeed = 0;
20856
6/6
✓ Branch 0 taken 210795 times.
✓ Branch 1 taken 51722 times.
✓ Branch 2 taken 120294 times.
✓ Branch 3 taken 90501 times.
✓ Branch 4 taken 113455 times.
✓ Branch 5 taken 6839 times.
262517 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
20857 97340 return;
20858 }
20859
20860 // Start writing the string
20861
2/2
✓ Branch 0 taken 163526 times.
✓ Branch 1 taken 2883 times.
169292 if(msgptr == 0)
20862 {
20863
2/2
✓ Branch 0 taken 2883 times.
✓ Branch 1 taken 5068 times.
7951 while(MsgStrings[msgstr].s[msgptr]==' ')
20864 {
20865 5068 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
20866
20867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
5156 if(cursor_x+tlength > (msg_w-msg_margins[right])
20868
4/6
✓ Branch 0 taken 4980 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
5068 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20869 ? 1 : strcmp(s3," ")!=0))
20870 {
20871 88 ssc_tile_hei = ssc_tile_hei_buf;
20872
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20873 88 ssc_tile_hei_buf = -1;
20874 88 cursor_y += thei + MsgStrings[msgstr].vspace;
20875
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(bottom_margin_clip()) break;
20876 88 cursor_x=msg_margins[left];
20877 88 }
20878
20879 5068 cursor_x+=tlength;
20880 5068 ++msgptr;
20881 5068 ++msgpos;
20882
20883 // The "Continue From Previous" feature
20884
2/2
✓ Branch 0 taken 3700 times.
✓ Branch 1 taken 1368 times.
5068 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
20885 {
20886
1/2
✓ Branch 0 taken 1368 times.
✗ Branch 1 not taken.
1368 if(MsgStrings[msgstr].nextstring)
20887 {
20888 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20889 {
20890 msgstr=MsgStrings[msgstr].nextstring;
20891 msgpos=msgptr=0;
20892 msgfont=setmsgfont();
20893 }
20894 }
20895 1368 }
20896 }
20897 2883 }
20898
20899 reparsesinglechar:
20900 // Continue printing the string!
20901
3/4
✓ Branch 0 taken 159832 times.
✓ Branch 1 taken 6579 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 159832 times.
326240 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
20902 {
20903
6/6
✓ Branch 0 taken 158869 times.
✓ Branch 1 taken 963 times.
✓ Branch 2 taken 158845 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 2750 times.
✓ Branch 5 taken 156095 times.
159832 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
20904 {
20905 156095 wrapmsgstr(s3);
20906
20907 156095 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20908
20909
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1867 times.
158218 if(cursor_x+tlength > (msg_w-msg_margins[right])
20910
6/6
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 153929 times.
✓ Branch 2 taken 2123 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 1867 times.
✓ Branch 5 taken 43 times.
156095 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20911 256 ? true : strcmp(s3," ")!=0))
20912 {
20913 2123 ssc_tile_hei = ssc_tile_hei_buf;
20914
1/2
✓ Branch 0 taken 2123 times.
✗ Branch 1 not taken.
2123 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20915 2123 ssc_tile_hei_buf = -1;
20916 2123 cursor_y += thei + MsgStrings[msgstr].vspace;
20917
1/2
✓ Branch 0 taken 2123 times.
✗ Branch 1 not taken.
2123 if(bottom_margin_clip()) goto strendcheck;
20918 2123 cursor_x=msg_margins[left];
20919 //if(space) s3[0]=0;
20920 2123 }
20921
20922 156095 sfx(MsgStrings[msgstr].sfx);
20923
20924 156095 char buf[2] = {0};
20925 156095 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
20926
20927 156095 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20928
20929 156095 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
20930 156095 cursor_x += MsgStrings[msgstr].hspace;
20931 156095 msgpos++;
20932 156095 }
20933
2/2
✓ Branch 0 taken 159831 times.
✓ Branch 1 taken 1 times.
159832 if(do_end_str)
20934 1 goto strendcheck;
20935
1/2
✓ Branch 0 taken 159831 times.
✗ Branch 1 not taken.
159831 if(wait_advance)
20936 {
20937 ++msgptr;
20938 return;
20939 }
20940
2/2
✓ Branch 0 taken 965 times.
✓ Branch 1 taken 158866 times.
159831 else if(do_run_menu)
20941 {
20942
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 963 times.
965 if(runMenuCursor())
20943 {
20944 2 do_run_menu = false;
20945 2 ++msgptr;
20946 2 goto reparsesinglechar;
20947 }
20948 963 }
20949
4/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 158836 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 24 times.
158866 else if(doing_name_insert && *nameptr)
20950 {
20951 24 char s3[9] = {0};
20952
20953
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
20954 {
20955 24 strcpy(s3, nameptr);
20956 24 }
20957 else
20958 {
20959 s3[0] = *nameptr;
20960 s3[1] = 0;
20961 }
20962
20963 24 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
20964
20965
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
24 if(cursor_x+tlength > (msg_w-msg_margins[right])
20966
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
20967 ? true : strcmp(s3," ")!=0))
20968 {
20969 ssc_tile_hei = ssc_tile_hei_buf;
20970 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20971 ssc_tile_hei_buf = -1;
20972 cursor_y += thei + MsgStrings[msgstr].vspace;
20973 if(bottom_margin_clip()) goto strendcheck;
20974 cursor_x=msg_margins[left];
20975 }
20976
20977 24 sfx(MsgStrings[msgstr].sfx);
20978
20979 24 char buf[2] = {0};
20980 24 sprintf(buf,"%c",*nameptr);
20981
20982 24 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
20983
20984 24 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
20985 24 cursor_x += MsgStrings[msgstr].hspace;
20986 24 ++nameptr;
20987 24 }
20988 else
20989 {
20990 158842 doing_name_insert = false;
20991 158842 msgptr++;
20992
20993
2/2
✓ Branch 0 taken 156149 times.
✓ Branch 1 taken 2693 times.
158842 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
20994 {
20995
2/2
✓ Branch 0 taken 1492 times.
✓ Branch 1 taken 1201 times.
2693 if(MsgStrings[msgstr].nextstring)
20996 {
20997
1/2
✓ Branch 0 taken 1201 times.
✗ Branch 1 not taken.
1201 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20998 {
20999 msgstr=MsgStrings[msgstr].nextstring;
21000 msgpos=msgptr=0;
21001 msgfont=setmsgfont();
21002 }
21003 1201 }
21004 2693 }
21005
21006
2/2
✓ Branch 0 taken 23711 times.
✓ Branch 1 taken 4519 times.
187072 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
21007
2/2
✓ Branch 0 taken 158321 times.
✓ Branch 1 taken 521 times.
158842 && (MsgStrings[msgstr].s[msgptr]==' ')
21008
2/2
✓ Branch 0 taken 28230 times.
✓ Branch 1 taken 130091 times.
158321 && (MsgStrings[msgstr].s[msgptr+1]==' '))
21009 {
21010
2/2
✓ Branch 0 taken 4513 times.
✓ Branch 1 taken 156761 times.
161274 while(MsgStrings[msgstr].s[msgptr]==' ')
21011 {
21012 156761 msgspace = true;
21013 156761 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21014
21015
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 6280 times.
163505 if(cursor_x+tlength > (msg_w-msg_margins[right])
21016
4/6
✓ Branch 0 taken 6744 times.
✓ Branch 1 taken 150017 times.
✓ Branch 2 taken 6744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6280 times.
✗ Branch 5 not taken.
156761 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21017 464 ? true : strcmp(s3," ")!=0))
21018 {
21019 6744 ssc_tile_hei = ssc_tile_hei_buf;
21020
1/2
✓ Branch 0 taken 6744 times.
✗ Branch 1 not taken.
6744 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21021 6744 ssc_tile_hei_buf = -1;
21022 6744 cursor_y += thei + MsgStrings[msgstr].vspace;
21023
2/2
✓ Branch 0 taken 6738 times.
✓ Branch 1 taken 6 times.
6744 if(bottom_margin_clip()) break;
21024 6738 cursor_x=msg_margins[left];
21025 6738 }
21026
21027 156755 cursor_x+=tlength;
21028 156755 ++msgpos;
21029 156755 ++msgptr;
21030
21031
2/2
✓ Branch 0 taken 10215 times.
✓ Branch 1 taken 146540 times.
156755 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21032 {
21033
2/2
✓ Branch 0 taken 87448 times.
✓ Branch 1 taken 59092 times.
146540 if(MsgStrings[msgstr].nextstring)
21034 {
21035
1/2
✓ Branch 0 taken 59092 times.
✗ Branch 1 not taken.
59092 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21036 {
21037 msgstr=MsgStrings[msgstr].nextstring;
21038 msgpos=msgptr=0;
21039 msgfont=setmsgfont();
21040 }
21041 59092 }
21042 146540 }
21043 }
21044 4519 }
21045 }
21046 159829 }
21047 strendcheck:
21048 // Done printing the string
21049
14/14
✓ Branch 0 taken 166408 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 166384 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 165421 times.
✓ Branch 5 taken 963 times.
✓ Branch 6 taken 164189 times.
✓ Branch 7 taken 1232 times.
✓ Branch 8 taken 161624 times.
✓ Branch 9 taken 2565 times.
✓ Branch 10 taken 161618 times.
✓ Branch 11 taken 6 times.
✓ Branch 12 taken 159216 times.
✓ Branch 13 taken 6205 times.
166409 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
21050 {
21051
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6205 times.
6206 if(!do_end_str)
21052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6205 times.
6205 while(parsemsgcode()); // Finish remaining control codes
21053
21054 // Go to next string, or make it disappear by going to string 0.
21055
5/6
✓ Branch 0 taken 4219 times.
✓ Branch 1 taken 1987 times.
✓ Branch 2 taken 3275 times.
✓ Branch 3 taken 944 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3275 times.
6206 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
21056 {
21057 2931 linkedmsgclk=do_end_str?1:51;
21058 2931 }
21059
21060
2/2
✓ Branch 0 taken 4219 times.
✓ Branch 1 taken 1987 times.
6206 if(MsgStrings[msgstr].nextstring==0)
21061 {
21062
2/2
✓ Branch 0 taken 944 times.
✓ Branch 1 taken 3275 times.
4219 if(!get_qr(qr_MSGDISAPPEAR))
21063 3275 {
21064 disappear:
21065 4218 msg_active = false;
21066 4218 Hero.finishedmsg();
21067 4218 }
21068
21069
2/2
✓ Branch 0 taken 5149 times.
✓ Branch 1 taken 13 times.
5162 if(repaircharge)
21070 {
21071 // if (get_qr(qr_REPAIRFIX)) {
21072 // fixed_door=true;
21073 // }
21074 13 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
21075 13 repaircharge = 0;
21076 13 }
21077
21078
2/2
✓ Branch 0 taken 5160 times.
✓ Branch 1 taken 2 times.
5162 if(adjustmagic)
21079 {
21080
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
21081 {
21082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(game->get_magicdrainrate())
21083 2 game->set_magicdrainrate(1);
21084 2 }
21085 else if(game->get_magicdrainrate() > 1)
21086 {
21087 game->set_magicdrainrate(game->get_magicdrainrate()/2);
21088 }
21089 2 adjustmagic = false;
21090 2 sfx(WAV_SCALE);
21091
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21092 2 }
21093
21094
2/2
✓ Branch 0 taken 5160 times.
✓ Branch 1 taken 2 times.
5162 if(learnslash)
21095 {
21096 2 game->set_canslash(1);
21097 2 learnslash = false;
21098 2 sfx(WAV_SCALE);
21099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21100 2 }
21101 5162 }
21102 7149 }
21103 14465949 }
21104
21105 124237 int32_t message_more_y()
21106 {
21107 //Is the flag ticked, do we really want a message more y larger than 160?
21108
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124209 times.
✓ Branch 2 taken 124237 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124209 times.
✓ Branch 5 taken 28 times.
124237 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
21109 124237 msgy+=playing_field_offset;
21110 124237 return msgy;
21111 }
21112
21113 /*** Collision detection & handling ***/
21114
21115 14167539 void clear_script_one_frame_conditions()
21116 {
21117
2/2
✓ Branch 0 taken 38764554 times.
✓ Branch 1 taken 14167539 times.
52932093 for(int32_t j=0; j<guys.Count(); j++)
21118 {
21119 38764554 enemy *e = (enemy*)guys.spr(j);
21120
2/2
✓ Branch 0 taken 658997418 times.
✓ Branch 1 taken 38764554 times.
697761972 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
21121 38764554 }
21122 14167539 }
21123
21124 4851789 void check_enemy_lweapon_collision(weapon *w)
21125 {
21126
8/8
✓ Branch 0 taken 4239709 times.
✓ Branch 1 taken 612080 times.
✓ Branch 2 taken 3250738 times.
✓ Branch 3 taken 988971 times.
✓ Branch 4 taken 3188654 times.
✓ Branch 5 taken 62084 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 3171916 times.
4851789 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
21127 {
21128
2/2
✓ Branch 0 taken 3156345 times.
✓ Branch 1 taken 11156732 times.
14313077 for(int32_t j=0; j<guys.Count(); j++)
21129 {
21130 11156732 enemy *e = (enemy*)guys.spr(j);
21131
21132 11156732 bool didhit = e->hit(w);
21133
2/2
✓ Branch 0 taken 10936278 times.
✓ Branch 1 taken 220454 times.
11156732 if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
21134 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
21135 {
21136 // !(e->stunclk)
21137 220454 int32_t h = e->takehit(w);
21138
2/2
✓ Branch 0 taken 187020 times.
✓ Branch 1 taken 33434 times.
220454 if (h == -1)
21139 {
21140 33434 int indx = Lwpns.find(w);
21141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33434 times.
33434 if(indx > -1)
21142 33434 e->hitby[HIT_BY_LWEAPON] = indx+1;
21143 33434 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
21144 33434 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
21145
2/2
✓ Branch 0 taken 31264 times.
✓ Branch 1 taken 2170 times.
33434 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
21146 2170 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
21147 33434 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
21148 33434 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
21149
21150 33434 }
21151 //we may need to handle this in special cases. -Z
21152
21153 //if h == stun or ignore
21154
21155 //if e->stun > DEFAULT_STUN -1 || !e->stun
21156 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
21157 ///! how about: if w->dead != bounce !
21158
21159 // NOT FOR PUBLIC RELEASE
21160 /*if(h==3) //Mirror shield
21161 {
21162 if (w->id==ewFireball || w->id==wRefFireball)
21163 {
21164 w->id=wRefFireball;
21165 switch(e->dir)
21166 {
21167 case up: e->angle += (PI - e->angle) * 2.0; break;
21168 case down: e->angle = -e->angle; break;
21169 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
21170 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
21171 // TODO: the following. -L.
21172 case l_up: break;
21173 case r_up: break;
21174 case l_down: break;
21175 case r_down: break;
21176 }
21177 }
21178 else
21179 {
21180 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
21181 w->dir ^= 1;
21182 if(w->dir&2)
21183 w->flip ^= 1;
21184 else
21185 w->flip ^= 2;
21186 }
21187 w->ignoreHero=false;
21188 }
21189 else*/
21190
2/2
✓ Branch 0 taken 176421 times.
✓ Branch 1 taken 44033 times.
220454 if(h)
21191 {
21192
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 44029 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
44033 if(e->switch_hooked && w->family_class == itype_switchhook)
21193 w->onhit(false, e, -1);
21194 44033 else w->onhit(false, e, h);
21195 44033 }
21196
21197
2/2
✓ Branch 0 taken 217780 times.
✓ Branch 1 taken 2674 times.
220454 if(h==2)
21198 {
21199 2674 break;
21200 }
21201 217780 }
21202
21203
2/2
✓ Branch 0 taken 11141161 times.
✓ Branch 1 taken 12897 times.
11154058 if(w->Dead())
21204 {
21205 12897 break;
21206 }
21207 11141161 }
21208
21209 // Item flags added in 2.55:
21210 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
21211 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
21212 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
21213 // -Em
21214
6/6
✓ Branch 0 taken 2717941 times.
✓ Branch 1 taken 453975 times.
✓ Branch 2 taken 2673369 times.
✓ Branch 3 taken 44572 times.
✓ Branch 4 taken 43559 times.
✓ Branch 5 taken 2629810 times.
3171916 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
21215 {
21216 542106 int32_t itype, pitem = w->parentitem;
21217
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 453975 times.
✓ Branch 2 taken 43559 times.
✓ Branch 3 taken 44572 times.
542106 switch(w->id)
21218 {
21219 453975 case wBrang: itype = itype_brang; break;
21220 43559 case wArrow: itype = itype_arrow; break;
21221 case wHookshot:
21222 44572 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
21223 44572 break;
21224 }
21225
2/2
✓ Branch 0 taken 537254 times.
✓ Branch 1 taken 4852 times.
542106 if(pitem < 0) pitem = current_item_id(itype);
21226
5/6
✓ Branch 0 taken 44572 times.
✓ Branch 1 taken 497534 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44472 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
542106 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
21227 { //Swap with item
21228 for(int32_t j=0; j<items.Count(); j++)
21229 {
21230 if(items.spr(j)->hit(w))
21231 {
21232 item *theItem = ((item*)items.spr(j));
21233 bool priced = theItem->PriceIndex >-1;
21234 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21235 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21236 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21237 {
21238 if(!Hero.switchhookclk)
21239 {
21240 hooked_combopos = -1;
21241 hooked_layerbits = 0;
21242 switching_object = theItem;
21243 theItem->switch_hooked = true;
21244 w->misc = 2;
21245 w->step = 0;
21246 theItem->clk2=256;
21247 Hero.doSwitchHook(game->get_switchhookstyle());
21248 if(QMisc.miscsfx[sfxSWITCHED])
21249 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
21250 }
21251 }
21252 }
21253 }
21254 }
21255
6/6
✓ Branch 0 taken 43559 times.
✓ Branch 1 taken 498547 times.
✓ Branch 2 taken 374087 times.
✓ Branch 3 taken 330528 times.
✓ Branch 4 taken 498547 times.
✓ Branch 5 taken 330528 times.
542106 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
21256 {
21257
2/2
✓ Branch 0 taken 87310 times.
✓ Branch 1 taken 374087 times.
461397 for(int32_t j=0; j<items.Count(); j++)
21258 {
21259
2/2
✓ Branch 0 taken 82412 times.
✓ Branch 1 taken 4898 times.
87310 if(items.spr(j)->hit(w))
21260 {
21261 4898 item *theItem = ((item*)items.spr(j));
21262 4898 bool priced = theItem->PriceIndex >-1;
21263
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4766 times.
4898 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21264
5/8
✓ Branch 0 taken 4898 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4898 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3789 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6963 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21265
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4898 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
21266 {
21267
1/2
✓ Branch 0 taken 1724 times.
✗ Branch 1 not taken.
5854 if(itemsbuf[theItem->id].collect_script)
21268 {
21269 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21270 }
21271
21272 1724 Hero.checkitems(j);
21273 1724 }
21274 4898 }
21275 87310 }
21276 374087 }
21277
2/2
✓ Branch 0 taken 14738 times.
✓ Branch 1 taken 153281 times.
829075 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21278 {
21279
2/2
✓ Branch 0 taken 36900 times.
✓ Branch 1 taken 153281 times.
190181 for(int32_t j=0; j<items.Count(); j++)
21280 {
21281
2/2
✓ Branch 0 taken 28212 times.
✓ Branch 1 taken 8688 times.
36900 if(items.spr(j)->hit(w))
21282 {
21283 8688 item *theItem = ((item*)items.spr(j));
21284 8688 bool priced = theItem->PriceIndex >-1;
21285
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8681 times.
8688 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21286
4/6
✓ Branch 0 taken 8688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8454 times.
✓ Branch 5 taken 234 times.
8688 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21287
5/10
✓ Branch 0 taken 7273 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8688 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21288 {
21289 7273 int32_t pickup = theItem->pickup;
21290 7273 int32_t id2 = theItem->id;
21291 7273 int32_t pstr = theItem->pstring;
21292 7273 int32_t pstr_flags = theItem->pickup_string_flags;
21293
21294 7273 std::vector<int32_t> &ev = FFCore.eventData;
21295 7273 ev.clear();
21296 7273 ev.push_back(id2*10000);
21297 7273 ev.push_back(pickup*10000);
21298 7273 ev.push_back(pstr*10000);
21299 7273 ev.push_back(pstr_flags*10000);
21300 7273 ev.push_back(0);
21301 7273 ev.push_back(theItem->getUID());
21302 7273 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21303 7273 ev.push_back(w->getUID());
21304
21305 7273 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21306 7273 bool nullify = ev[4] != 0;
21307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7273 times.
7273 if(nullify) continue;
21308
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6197 times.
7273 if(w->id == wBrang)
21309 {
21310 6197 w->onhit(false);
21311 6197 }
21312
21313
2/2
✓ Branch 0 taken 6775 times.
✓ Branch 1 taken 498 times.
7273 if(w->dragging==-1)
21314 {
21315 498 w->dead=1;
21316 498 theItem->clk2=256;
21317 498 w->dragging=j;
21318 498 theItem->is_dragged = true;
21319 498 }
21320 7273 }
21321 8688 }
21322 36900 }
21323 153281 }
21324 542106 }
21325 3171916 }
21326 4851789 }
21327 14165383 void check_collisions()
21328 {
21329
2/2
✓ Branch 0 taken 4851749 times.
✓ Branch 1 taken 14165383 times.
19017132 for(uint q = 0; q < Lwpns.Count(); ++q)
21330 4851749 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
21331 14165383 }
21332
21333 14167539 void dragging_item()
21334 {
21335
2/2
✓ Branch 0 taken 4967058 times.
✓ Branch 1 taken 14167539 times.
19134597 for(int32_t i=0; i<Lwpns.Count(); i++)
21336 {
21337 4967058 weapon *w = (weapon*)Lwpns.spr(i);
21338
21339
4/4
✓ Branch 0 taken 4504494 times.
✓ Branch 1 taken 462564 times.
✓ Branch 2 taken 4811799 times.
✓ Branch 3 taken 155259 times.
4967058 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
21340 {
21341
3/4
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 148012 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7247 times.
155259 if(w->dragging>=0 && w->dragging<items.Count())
21342 {
21343 7247 item* dragItem = (item*)items.spr(w->dragging);
21344 7247 dragItem->x=w->x;
21345 7247 dragItem->y=w->y;
21346
21347 // Drag the Fairy enemy as well as the Fairy item
21348 7247 int32_t id = dragItem->id;
21349
21350
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7247 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21351 {
21352 404 movefairynew2(w->x,w->y,*dragItem);
21353 404 }
21354 7247 }
21355 155259 }
21356 4967058 }
21357 14167539 }
21358
21359 55 int32_t more_carried_items()
21360 {
21361 55 int32_t hasmorecarries = 0;
21362
21363
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 55 times.
115 for(int32_t i=0; i<items.Count(); i++)
21364 {
21365
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 55 times.
60 if(((item*)items.spr(i))->pickup & ipENEMY)
21366 {
21367 55 hasmorecarries++;
21368 55 }
21369 60 }
21370
21371 55 return hasmorecarries;
21372 }
21373
21374 // messy code to do the enemy-carrying-the-item thing
21375 14167539 void roaming_item()
21376 {
21377
4/4
✓ Branch 0 taken 28207 times.
✓ Branch 1 taken 14139332 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 28137 times.
14167539 if(!(hasitem&(4|2)) || !loaded_enemies)
21378 14139402 return;
21379
21380 // All enemies already dead upon entering a room?
21381
1/2
✓ Branch 0 taken 28137 times.
✗ Branch 1 not taken.
28137 if(guys.Count()==0)
21382 {
21383 return;
21384 }
21385
21386 // Lost track of the carrier?
21387
5/6
✓ Branch 0 taken 28137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28131 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 28115 times.
✓ Branch 5 taken 16 times.
28137 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
21388 28131 !((enemy*)guys.spr(guycarryingitem))->itemguy)
21389 {
21390 22 guycarryingitem=-1;
21391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 for(int32_t j=0; j<guys.Count(); j++)
21392 {
21393
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 22 times.
84 if(((enemy*)guys.spr(j))->itemguy)
21394 {
21395 22 guycarryingitem=j;
21396 22 break;
21397 }
21398 62 }
21399 22 }
21400
21401
2/2
✓ Branch 0 taken 28073 times.
✓ Branch 1 taken 64 times.
28137 if(hasitem&4)
21402 {
21403 64 guycarryingitem = -1;
21404
21405
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 64 times.
477 for(int32_t i=0; i<guys.Count(); i++)
21406 {
21407
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 64 times.
413 if(((enemy*)guys.spr(i))->itemguy)
21408 {
21409 64 guycarryingitem = i;
21410 64 }
21411 413 }
21412
21413
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(guycarryingitem == -1) //This happens when "default enemies" such as
21414 {
21415 return; //eSHOOTFBALL are alive but enemies from the list
21416 } //are not. Defer to HeroClass::checkspecial().
21417
21418 64 int32_t Item=tmpscr->item;
21419
21420 64 hasitem &= ~4;
21421
21422
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21423 {
21424 115 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
21425
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 13 times.
64 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21426 );
21427 64 hasitem |= 2;
21428 64 }
21429 else
21430 {
21431 return;
21432 }
21433 64 }
21434
21435
2/2
✓ Branch 0 taken 29483 times.
✓ Branch 1 taken 28137 times.
57620 for(int32_t i=0; i<items.Count(); i++)
21436 {
21437
2/2
✓ Branch 0 taken 1346 times.
✓ Branch 1 taken 28137 times.
29483 if(((item*)items.spr(i))->pickup&ipENEMY)
21438 {
21439
2/2
✓ Branch 0 taken 14272 times.
✓ Branch 1 taken 13865 times.
28137 if(get_qr(qr_HIDECARRIEDITEMS))
21440 {
21441 14272 items.spr(i)->x = -128; // Awfully inelegant, innit?
21442 14272 items.spr(i)->y = -128;
21443 14272 }
21444
2/4
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13865 times.
13865 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21445 {
21446
1/2
✓ Branch 0 taken 13865 times.
✗ Branch 1 not taken.
13865 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21447 {
21448 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21449 {
21450 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21451 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21452 }
21453 else
21454 {
21455 if(guys.spr(guycarryingitem)->extend >= 3)
21456 {
21457 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21458 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21459 }
21460 else
21461 {
21462 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21463 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21464 }
21465 }
21466 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21467 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21468 }
21469 else
21470 {
21471 13865 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21472 13865 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21473 13865 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21474 }
21475 13865 }
21476 28137 }
21477 29483 }
21478 14167539 }
21479
21480 bool enemy::IsBigAnim()
21481 {
21482 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21483 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21484 || anim == a4FRM8DIRB);
21485 }
21486 2389602 int32_t enemy::getFlashingCSet()
21487 {
21488 //Special cset for the dying sprite
21489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2389602 times.
2389602 if(dying)
21490 {
21491 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21492 return wpnsbuf[spr_death].csets & 15;
21493 else
21494 return (((clk2 + 5) >> 1) & 3) + 6;
21495 }
21496
21497 //Normal cset
21498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2389602 times.
2389602 if (hclk <= 0)
21499 {
21500 //Special cset for the flashing animation
21501 if (flags2 & guy_flashing)
21502 return (frame & 3) + 6;
21503 return cs;
21504 }
21505
21506 //Hurt animations
21507
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2385714 times.
2389602 if(family==eeGANON)
21508 3888 return (((hclk-1)>>1)&3)+6;
21509
4/4
✓ Branch 0 taken 2216853 times.
✓ Branch 1 taken 168861 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1729715 times.
2385714 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21510 1729715 return (((hclk-1)>>1)&3)+6;
21511
21512 655999 return cs;
21513 2389602 }
21514
21515 81522434 bool enemy::is_hitflickerframe(bool olddrawing)
21516 {
21517
6/6
✓ Branch 0 taken 81493930 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 3940256 times.
✓ Branch 3 taken 77553674 times.
✓ Branch 4 taken 3167565 times.
✓ Branch 5 taken 772691 times.
81522434 if (family == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21518 80749743 return false;
21519
21520
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
21521 return false;
21522
21523 772691 int32_t fr = game->get_spriteflickerspeed();
21524
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
21525 return true;
21526 772691 return frame % (fr * 2) < fr;
21527 81522434 }
21528
21529 const char *old_guy_string[OLDMAXGUYS] =
21530 {
21531 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21532 // 020
21533 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21534 // 025
21535 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21536 // 030
21537 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21538 // 035
21539 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21540 // 040
21541 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21542 // 045
21543 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21544 // 050
21545 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21546 // 055
21547 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21548 // 060
21549 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21550 // 065
21551 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21552 // 070
21553 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21554 // 075
21555 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21556 // 080
21557 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21558 // 085
21559 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21560 // 090
21561 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21562 // 095
21563 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21564 // 100
21565 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21566 // 105
21567 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21568 // 110
21569 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21570 // 115
21571 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21572 // 120
21573 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21574 // 125
21575 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21576 // 130
21577 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21578 // 135
21579 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21580 // 140
21581 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21582 // 145
21583 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21584 // 150
21585 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21586 // 155
21587 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21588 // 160
21589 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21590 // 165
21591 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21592 // 170
21593 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21594 // 175
21595 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21596 };
21597